Getting a Reference to a Running BPEL Process
I was on a course last week with one of my team, learning about Oracles COREid Identity & Access Management product set, when we got a text from another team member asking how, when using the web service invocation of a BPEL process, to get the process ID. Given that he asked the question I assume that there must be other people wondering the same thing.
How to Get BPEL Process ID from BPEL PM
Oracle BPEL Process Manager provides a handy XPath extension to retrieve the "Instance ID" of a BPEL process instance. Note that the "Process ID" is the ID of the deployed process, not the ID of the process instance. You will almost always want the instance ID. The XPath extension is
ora:getInstanceId()
This function returns a xsd:string type. The complete Process reference is constructed in Java using the ReferenceId class. This uses the domain and the instance ID to create a unique reference.
ReferenceId refId = new ReferenceId("default", iid);
locator.lookupInstance(refId.toString());
The locator.lookupInstance method allows us to query the state of a process, retrieves its result and generally manipulate it, for example aborting it.
How do we get the ID?
We probably want the instance ID because we need to interact with an asynchronous process. The next obvious question is how do we get the ID back to the invoker. The answer is simple. We modify our asych process to return a synchronous result from the initial invocation. We use this to return the ID, it also confirms to the requestor that the BPEL PM has received the request and has initiated a process.
I have attached a
sample BPEL process with
WSDL, along with
some Java and a
jndi.properties file to demonstrate this.