Monday, May 17, 2010

Invoke BPEL using Java API

This article helps you in kick start of creating your own BPEL console or automate program to do certain activities which BPEL console can perform.

All the operations performed in BPEL console can be created using the java API.

BPEL processes can be invoked using a Java API. The API will differ depending upon the type of operation involved. One way operation has an input message without result. Two way operations send and receive the message.

Refer Java API : http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm

Note: orabpel.jar files should be added in the classpath


package com.bpel.client;

import com.oracle.bpel.client.*;
import com.oracle.bpel.client.dispatch.*;

import java.util.Map;
import java.util.Properties;


public class InvokeBPEL
{

/**
*
* @author Ziaur Rahuman S
*/
public static void main(String[] args)
{

Properties props = new Properties();

props.setProperty("orabpel.platform", "ias_10g");
props.setProperty("java.naming.factory.initial",
"com.evermind.server.rmi.RMIInitialContextFactory");
props.setProperty("java.naming.provider.url",
"opmn:ormi://hostname:6003:oc4j_soa/orabpel");
props.setProperty("java.naming.security.principal", "oc4jadmin");
props.setProperty("java.naming.security.credentials", "oc4jadm1n");
props.setProperty("dedicated.connection", "true");


String xml = "<SyncHelloWorldProcessRequest><input>World</input></SyncHelloWorldProcessRequest>";

try {
// Create instance of Locator object with domain name and password as arguement
Locator locator = new Locator("ocoetest", "oc4jadm1n", props);
IDeliveryService dService = (IDeliveryService) locator.lookupService(IDeliveryService.SERVICE_NAME);

// Create normalized message with payload
NormalizedMessage nm = new NormalizedMessage();
nm.addPart("payload", xml);

// Invoke two way operation
NormalizedMessage response = dService.request("SyncHelloWorld","process",nm);
Map payload = response.getPayload();

// Invoke one way operation
//dService.post("AsyncHelloWorld","initiate",nm);

System.out.println("SyncHelloWorld Invoked Successfully !!!");

} catch (Exception e)
{
e.printStackTrace();
}


}
}


No comments:

Post a Comment