Wednesday, April 11, 2007

Oracle BPEL Process Manager Client API

We did not find direct WebCenter way to access the BPEL process, but we found API “Oracle BPEL Process Manager Client API”.

This API support invoking the BPEL Process programmatically via a Java Code. The API is slightly different depending on whether you are invoking a two-way operation (which has both input and output messages) Synchronous proces or a one-way operation (which just has an input message and returns no result) Asynchronous process .

So this API provides to us two services Post Service and Request Service where its using depends on the type of BPEL process.

Asynchronous BPEL Process:
It provides only initiate operation which has input without output so we use post function to access this Operation.

Synchronous BPEL Process:
It provides only also Process operation which has input and out put so we use request function to access this operation.

**********************************************************************
How we use this API?


1- Setting the configuration for connecting to Oracle BPEL Process Manger.
Hashtable jndi = new Hashtable ();
jndi.put (Context.PROVIDER_URL, "opmn:ormi://10.10.2.141:6003/orabpel");
jndi.put (Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
jndi.put (Context.SECURITY_PRINCIPAL,”oc4jadmin”); // username of Bpel Manager
jndi.put (Context.SECURITY_CREDENTIALS,”welcome1”); //password of BPEL Manager
jndi.put ("dedicated.connection",”true”);

Locator = new Locator (“default”,”welcome1”); // default is the domain Name and welcome1 is the
Password of the domain.

deliveryService = (IDeliveryService) locator.lookupService (IDeliveryService.SERVICE_NAME);

Locator class: used to connect to the domain on the BPEL Process Manager and fetch a list of BPEL processes deployed on that server. In this case, we use the Locator class to return a handle to an IDeliveryService instance.
IDeliveryService Interface: used to invoke/initiate BPEL processes deployed on a BPEL Process Manager.

2- Passing XML messages via Java.
String SchemaInputXML = "" +
" ererer " +
" dgfdggdg " +
"
";
nm = new NormalizedMessage ();
nm.addPart ("payload", SchemaInputXML);


NormalizedMessage class: construct an XML message, construct an input message for request or construct an Output Message for response.

3- Invoking the operation.

Invoking Synchronous Process:
It call process operation which return output message and need input message
So we use the IDeliveryService.request () methods to access this process.

NormalizedMessage res = deliveryService.request ("userBPEL", "process", nm);
// userBPEL is Process Name and process is operation method name and nm is the input message.

Invoking Asynchronous Process:
It call initiate operation which need input message and does not return output so
We use IDEliveryService.post () method to access this process.

deliveryService.post (“userBPEL”,”initiate”, nm);

**********************************************************************
How to retrieve the Result?

Synchronous process:
It is easy to retrieve the result using normalizedMessage object as we saw in the synchronous invoking.

Asynchronous process:
It is not easy to get the result but we can inform the user of the process by making the Process send JMS Message or email (I did not try it ...I just read it) Or using conversation ID to identify the process instance before posting and after that use this ID to identify a specific instance and retrieve status information from it .

String convId = GUIDGenerator.generateGUID();
nm.setProperty(NormalizedMessage.CONVERSATION_ID, convId);
deliveryService.post(processID,operationName, nm);
IInstanceHandle fg = (IInstanceHandle)locator.lookupInstanceByConversationId(convId);

**********************************************************************
What we need to use this API?

oc4jclient.jar, Orabpel-common.jar and Orabpel.jar

2 comments:

Anonymous said...

Hi Sara,
Very good job.

But usually I don't prefer to use Oracle API's for WS & XML stuff. So, sometimes the caller will be webservice or SOAP/HTTP.

How will you return the BPEL process ID to the caller?

Keep up the good work.

Ahmed Hashim

Unknown said...

The jndi variable you define has no purpose.