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
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
//sets jndi factory class, this is used to locate remote RMI server
//sets target url for target rmi server (oc4j
//sets user name for the remote server
//sets password for the remote server

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.