Consuming Async SOA in a WebService Proxy
By Anagha Desai on Feb 27, 2014
Consider a scenario where an application is built using SOA Async processes and needs to be consumed in a WebService Proxy. In this blog, we will be demonstrating how to implement this use case. To achieve this, we will follow a two step process:
- Create an Async SOA BPEL process.
- Consume it in a WebService Proxy.
Jdeveloper with SOA extension installed.
To begin with step 1, create a SOA Application and name it SOA_AsyncApp.
This invokes Create SOA Application wizard. In the wizard, choose composite with BPEL process in Step 3.
As we are going to build an async processes, in Create BPEL Process dialog, choose Asynchronous BPEL Process from Template drop-down. We will be using BPEL 1.1 Specification for our process. Also, make sure the process is exposed as a SOAP service.
We can see the two one-way operations listed in the process wsdl as it is an async process:
Drag and drop assign activity from Components onto the SOA Composite.
Edit the assign activity to insert a new rule from input variable payload to output variable payload. Click on the Plus symbol to add the rule.
Now, the Async service setup is complete and the project containing Async process can be deployed to a SOA server. With this, we are done with Step 1 of our use case.
To create a proxy for this service, create a custom Application SOA_AsyncProxy. Invoke Create Web Service Proxy wizard and in Step 2 of wizard, give WSDL of the service developed in Part1 of this blog. In Step 3, check ‘Generate As Async ’ checkbox and give Callback Package name CallBackPackage.
In step 5, make sure generate async method radio button is selected and finish the wizard.
After proxy is generated, run the Callback Service from under the package CallBackPackage. This service will listen to the response from the asynchronous service. Give target URL of Callback Service in proxy class and call the process with appropriate input value.
Run the proxy. Following sequence of actions will take place after proxy is run:
1) The proxy will invoke the SOA process asynchronously and continue with other tasks.
2) SOA async service will store the request and send receipt confirmation (202) to the proxy.
3) The service processes the request and acting as a proxy for Callback Service, sends the response back to the Callback Service.
4) Callback service, deployed on the proxy side receives the response and sends a confirmation to the async SOA service (202).
After the callback service receives the response, it has to map the response to the request. This is achieved using WS-Addressing Headers. The proxy must set two fields to establish the correlation: 1) ReplyTo address (address of the Callback Service) and 2) A unique Id to identify the request.
Async behavior can be verified by logging in to EM console and examining the flow instance of BPEL Process.
The correct payload in the callbackProxy confirms that async operation has been executed successfully.