Today we are going to design an OSB proxy service which will invoke an Async SOA BPEL service with the help of SOA-Direct binding.
Before that we will check few quick things:
What is Asynchronous pattern and how it is different from Synchronous design pattern:
When you invoke a Web service synchronously, the invoking client application waits for the response to return before it can continue with its work. In cases where the response returns immediately, this method of invoking the Web service might be adequate. However, because request processing can be delayed, it is often useful for the client application to continue its work and handle the response later on. By calling a Web service asynchronously, the client can continue its processing, without interrupt, and will be notified when the asynchronous response is returned.
or
You can take "Endpoint URI" from "location" attribute under <Service> tag of AsynchronousComposite Wsdl file.
Now Go to Edit Route.
Before that we will check few quick things:
What is Asynchronous pattern and how it is different from Synchronous design pattern:
When you invoke a Web service synchronously, the invoking client application waits for the response to return before it can continue with its work. In cases where the response returns immediately, this method of invoking the Web service might be adequate. However, because request processing can be delayed, it is often useful for the client application to continue its work and handle the response later on. By calling a Web service asynchronously, the client can continue its processing, without interrupt, and will be notified when the asynchronous response is returned.
Problem
When a service needs to respond to a consumer request through the issuance of multiple messages or when service message processing requires a large amount of time, it is often not possible to communicate synchronously.
Solution
A service can require that consumers communicate with it asynchronously and provide a callback address to which the service can send response messages.
Application
A callback address generation and message correlation mechanism needs to be incorporated into the messaging framework and the overall inventory architecture.
Impacts
Asynchronous communication can introduce reliability concerns and can further require that surrounding infrastructure be upgraded to fully support the necessary callback correlation.
Main points to be kept in mind while designing & invoking Async Service:
Service A sends a message containing the callback address and correlation information to Service B (1). While Service B is processing the message, Service A is unblocked (2). Service B, at some later point in time, sends a response containing the correlation information to the callback address to Service A (3). While Service B retains this callback address, it can continue to issue subsequent response messages to Service A.
Implementation:
First of all we need to have Asynchronous web service. I created one Asynchronous BPEL process that we will invoke from Oracle Service Bus.
In this post, we will use “soa-direct” OSB protocol to connect to Asynchronous SOA service. For this one you need to use Direct Binding in Asynchronous web service instead of default binding. To change the binding go to Composite.xml and comment out binding.ws part inside service tag.
Service tag with Direct Binding
<service name="asynchronousbpelprocess_client_ep"
ui:wsdlLocation="AsynchronousBPELProcess.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/TestApplication/AsynchronousComposite/AsynchronousBPELProcess#wsdl.interface(AsynchronousBPELProcess)"
callbackInterface="http://xmlns.oracle.com/TestApplication/AsynchronousComposite/AsynchronousBPELProcess#wsdl.interface(AsynchronousBPELProcessCallback)"/>
<binding.direct/>
</service>
Since we added Direct Binding in comspoite.xml file so you can’t get WSDL and Schema files directly from EM console. To get the WSDL and schema file go to http://host:8001/soa-infra/ login with your credentials and select your deployed service and save WSDL and schema files.
Step 1: Create a new OSB project and import Asynchronous web service WSDL and import.
Step 2: Before creating Business service, we require Call Back proxy service that we will use in business service.
- Click on “proxy” folder and choose “Proxy Service” as “Select Resource Type” from Create Drop down list.
- Give it any name and choose “WSDL Web Service” as Service Type. Click on Browse button and select previously imported WSDL file.
- Choose AsynchronousBPELProcessCallBackDirectBinding1.2 from Bindings and click Submit. Then click on Next button.
- Choose “sb” protocol and click next.
- Accept default values and we have call back proxy service ready. Now we can move to Business service creation.
- Click on “business” folder and choose “Business Service” as “Select Resource Type” from Create Drop down list.
- Give it any name and choose “WSDL Web Service” as Service Type. Click on Browse button and select previously imported WSDL file.
- Select “AsynchronousBPELProcessDirectBinding1.2” from WSDL definitions. Click Submit and then go to Next step.
- Choose “soa-direct” protocol and check server host and port in Endpoint URI and click on Add button. Then click on Next button.
t3://localhost:8001/default/AsynchronousComposite!1.0/asynchronousbpelprocess_client_ep
Where t3 is protocol, 8001 is port for soa server, default is web logic domain, AsynchronousComposite!1.0 is name of composite with version ( project), asynchronousbpelprocess_client_ep is name of the service tag inside wsdl file.
or
You can take "Endpoint URI" from "location" attribute under <Service> tag of AsynchronousComposite Wsdl file.
- Select “Asynchronous client” as Role. Then browse for Call Back proxy service and choose previously created Call Back proxy service.
- Accept Default values and you are ready with Business service.
Step 4: Now we will create Proxy service that will invoke Business service that we just created.
- Click on “proxy” folder and choose “Proxy Service” as “Select Resource Type” from Create Drop down list.
- Give it any name and choose “WSDL Web Service” as Service Type. Click on Browse button and select previously asynchronous web service WSDL file.
- Select Direct Binding port. Accept Default values.
- Now we are ready with Client proxy service.
Step 4: Only step remaining is to connect Client proxy service to Business Service.
- Go to Client proxy Service Message flow.
- Add Route Activity to proxy service flow to call Business Service. You can edit the name of the route activity.
- Add a new Action “Routing” inside Route Node.
- Choose Business Service. And choose operation for the Business Service.
This is it. Now we are ready to test it.
Testing Scenario: From Outside we will invoke Client Proxy service then Client proxy service will invoke Business Service which in turn calls Asynchronous web service. Asynchronous will process the message and send the response back asynchronously. Call back proxy catch that response and we can do whatever we want to do there.
Hey,
ReplyDeleteI got a question about Asyns Service Testing.
Use case below:
1.Create one local async service with callback
2.Create one SOAP UI project with local async service.
3.Create one Mock service on SOAP UI.
4.provide mock service URL in SOAP UI main method.
5.Execute service.
6.Callback response in mock service.
Done!!!!
Issue will be when you deploy your service on remote server/cloud and implement same case where you provided mock service URL in callback URL in SOAP UI.
You just need to connect with your network team and take help from them so your machine can be accessible from that remote server/cloud server.
For remote server access testing, You can ping your machine IP on remote server, if it is fine then your mock service callback will done without any issue.
DeleteSample SOA & OSB code is available in google drive.
ReplyDeletehttps://drive.google.com/file/d/0BzvVcpM2dprBbFZOSGpkMkJpUlE/view?usp=sharing
Received a query over linkedin:
ReplyDeleteHow to return callback response from JMS to end client using some sync service?
Ans: This is not possible due to following reasons:
1.When callback response will be inserted in JMS queue, You can only consume that response JMS queue message by only OSB proxy service which will be again a polling service or you can create a SOA project which will again a polling service.
So it is not possible to read JMS queue message in between OSB proxy or SOA BPEL,
So what is alternative of this implementation??
1.Create a table in a data base, with 2 column, callbackResponse and messageid.
2.Insert data in this table from callback proxy (Replace JMS insert task from proxy 2)
3.Create one business service which will read data from this table based on messageID of table.
4.Create one proxy and call new created business service.
with this solution you can return response in sync way.
But it's not a good way to implementation async, Right implementation is to use callback URL which will provided by end client.
But in the blog of making async service a sync service in osb we used a jms
ReplyDeleteNice post ,keep update at
ReplyDeleteOracle SOA Online Training Bangalore
Appian BPM online training
ReplyDeleteAppian BPM training
arcsight online training
arcsight training
Build and Release online training
Build and Release training
Dell Bhoomi online training
Dell Bhoomi training
Dot Net online training
Dot Net training
ETL Testing online training
ETL Testing training
Hadoop online training
Hadoop training
Tibco online training
Tibco training
Thank You For Sharing This OSB ORACLE
ReplyDeleteOSB Online Training Hyderabad
Thanks for the post, perhaps you have this in osb 12c and soa 12c ?
ReplyDelete