Tuesday, July 11, 2006

Invoking from JSP & using guid

Invoking BPEL process from JSP???...with a requirement to know a unique identifier earlier on ... So ended up using the java API.It was a savior a day before the deadline:).....

The following entry invokes bpel process from jsp as well as shows how we can have another unique identifier (apart from the bpel instance id that we get to know about at a later stage):


First,
I need to have an XML rep of the payload that i will be sending to the BPEL process from the JSP. This is done as follows:
String xml = "" +
"" +year+ "" +
"" +fname+ "" +
"" + lname +"
"
";

Second,
Locator: This helps you look for a process inst that is deployed in the domain.
Delivery Service:used to invoke instances.

Locator locator = new Locator("default","bpel");//default domain
com.oracle.bpel.client.dispatch.IDeliveryService deliveryService = (com.oracle.bpel.client.dispatch.IDeliveryService) locator.lookupService(com.oracle.bpel.client.dispatch.IDeliveryService.SERVICE_NAME);

Third,
Normalized Message: this is what is used as means of communication between the bpel client and orabpel delivery service.
com.oracle.bpel.client.NormalizedMessage nm = new com.oracle.bpel.client.NormalizedMessage();

You can get a unique identifier for your BPEL process using:
String uniqueBpelId = com.collaxa.cube.util.GUIDGenerator.generateGUID();

To the normalized message you attach the payload - that is what you are passing to the bpel process.

java.util.Map msgProps = new HashMap();//one fo the formats for Normalized message is java.util.map(name/value pair)

msgProps.put("conversationId",uniqueBpelId);
nm.setProperty("conversationId",uniqueBpelId);//to set the property for this message
nm.addPart("payload",xml);//to add to the payload of this message
deliveryService.post("bpelprocess","initiate",nm);//post method returns void.

Conclusion:
Above we(client) are specifying a conversation id that is unique to identify any BPEL process instance. Not that badd!!!!!:)

0 Comments:

Post a Comment

<< Home