A Quick Response
By Antony Reynolds on Sep 25, 2007
A Quick Response
Returning an Immediate Response from an Asynch ProcessI just got asked by a colleague how to return an immediate response from a BPEL process created using the template "Asynchronous BPEL Process". Often we want to return some data to the caller of a process to indicate that the request has been received and is being processed. To do this we need to add an immediate response to the caller in addition to calling them back later when the process is completed. For example consider a process to make a booking for some resource. The process might be lengthy and the caller may need some mechanism for canceling the process before it completes. In this case returning an immediate response could give the caller a handle allowing him to call back into the specific process instance to cancel it.
So lets look at how we alter the template to allow for this immediate response.
Create the ProjectFirst we create our process using File->New Project in JDeveloper and choose a BPEL PRocess Project and select the "Asynchronous BPEL Process" template.
Adding a Response ElementOnce we have created our project we then need to add an immediate response element to the XSD.
<element name="result" type="string"/>
Adding a New Message TypeHaving created a new immediate response element to the XSD we then need to use that element within a new message type in the WSDL.
<part name="payload" element="client:ImmediateResponseBPELProcessProcessImmediateResponse"/>
Adding an Output to the Initiate OperationWithin the port type for the process we need to modify the "initiate" operation to return an immediate response of the message type we just created.
Adding a New Variable to the ProcessWe need to add a new variable to the process to hold the immediate return value.
Add a Reply to the ProcessWe can add the reply operation to the process and wire it up the client partner link.
Complete ProcessFinally we need to complete the process. I will often return the process instance ID as a return value. This can then be used a correlation token if the client needs to call into the process again before it completes.
Once the process is finished being written it can be deployed and executed.