Jul 29, 2008

Invoking BPEL from Java

1> Import following libraries to project properties -
a> <jdev_home>/intergration/lib
orabpel.jar, orabpel-common.jar, orabpel-thirdparty.jar
b> <jdev_home>/j2ee/home
oc4jclient.jar
c> Add J2EE

2> Create Properties, add following properties in java client
Properties props = new java.util.Properties();
//sets target bpel platform, oracle installation, this will be oc4j_10g
props.setProperty("orabpel.platform","oc4j_10g");
//sets jndi factory class, this is used to locate remote RMI server
props.setProperty("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
//sets target url for target rmi server (oc4j
props.setProperty("java.naming.provider.url","opmn:ormi://172.28.10.138:6003:oc4j_soa/orabpel");
//sets user name for the remote server
props.setProperty("java.naming.security.principal","oc4jadmin");
//sets password for the remote server
props.setProperty("java.naming.security.credentials","welcome1");

3> Create message to be post to BPEL process
String ssn = "lalit";
// construct the normalized message
String xml = "<input xmlns=\"http://xmlns.oracle.com/HelloWorld\">" + ssn + "</input>";
NormalizedMessage nm = new NormalizedMessage();
//payload is specific to the process you invoke, it is defined in the WSDL used by your BPEL process
nm.addPart("payload", xml );

4> Call BPEL using orabpel api as
Locator locator = new Locator("<domain name>", "<domain password>", props);

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

//Invoking bpel process
NormalizedMessage res = deliveryService.request("<bpel process name>", "<operation name>", nm);

//Since we used request, we can retrieve the return message
Map payload = res.getPayload();

Using Map object you can extract payload.

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi guys,
    The above concept is good for synchronous BPEL process where a two way communication is done by using request method and the return message from the BPEL process is also successfully retrived.
    To call an asynchronous BPEL process,we can use the request method to initiate it,but we cannot retrieve the return message.
    To retrieve the return message from the BPEL process we need to use post method.

    ReplyDelete