In previous posts (post1 & post2), we have seen how to use SOAP and Remote clients to work with BPM Java APIs. One immediate problem we can see is using server urls in the code which makes deployment across environments difficult. In this post, we will see how to take care of this.
WorkflowServiceClientFactory class has different overloaded methods to get the client. When we don’t pass any properties like below, BPM run time will look for a file wf_client_config.xml in classpath of ear file.
private IWorkflowServiceClient getWfServiceClient() { IWorkflowServiceClient wfSvcClient = null; wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT); return wfSvcClient; }
We can create wf_client_config.xml with the following contents having the server details and information pertaining to both SOAP and REMOTE clients. The file can be placed in a folder like conf under our project folder.
<?xml version="1.0" encoding="UTF-8"?> <workflowServicesClientConfiguration xmlns="http://xmlns.oracle.com/bpel/services/client"> <server name="default" default="true"> <remoteClient> <serverURL>t3://localhost:7005/soa-infra</serverURL> <userName>weblogic</userName> <password>weblogic1</password> <initialContextFactory>weblogic.jndi.WLInitialContextFactory</initialContextFactory> <participateInClientTransaction>false</participateInClientTransaction> </remoteClient> <soapClient> <rootEndPointURL>http://localhost:7005</rootEndPointURL> <identityPropagation mode="dynamic" type="saml"> <policy-references> <policy-reference enabled="true" category="security" uri="oracle/wss10_saml_token_client_policy"/> </policy-references> </identityPropagation> </soapClient> </server> </workflowServicesClientConfiguration>
Include this file in the ear deployment profile using the below steps i.e. corresponding to ADF BC Service project. Create new file group APP-INF/classes as shown below.
Add the contributor pointing to conf directory having wf_client_config.xml file.
Now filters section of APP-INF/classes group should be shown like below.
Deploy the ear file and re-test your webservice method.
During testing, if the following error is seen in the logs make sure that <?xml version = ‘1.0’ encoding = ‘UTF-8’?> is present as first line in wf_client_config.xml file.
[Exception [EclipseLink-25008] (Eclipse Persistence Services – 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element workflowServicesClientConfiguration was not found in the project]
Since the server details are externalized you can use tokens in wf_client_config.xml and replace them using actual server urls before deploying to specific environments.
0 Responses to “Using BPM Java API – wf_client_config.xml”