Saturday, August 25, 2012

In my previous post I explained how to call Synchronous SOA service from Oracle Service Bus using soa-direct protocol. In this post I will explain you how to call Asynchronous SOA service from Oracle Service Bus.

OSB to SOA Call using soa-direct


Only difference between Synchronous and Asynchronous call is, in case of Asynchronous call we need to created extra “Call Back Proxy Service” which gets the response back from Asynchronous SOA service.

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-directOSB 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.


Original service tag
<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.ws port="http://xmlns.oracle.com/TestApplication/AsynchronousComposite/AsynchronousBPELProcess#wsdl.endpoint(asynchronousbpelprocess_client_ep/AsynchronousBPELProcess_pt)"/>
    <callback>
      <binding.ws port="http://xmlns.oracle.com/TestApplication/AsynchronousComposite/AsynchronousBPELProcess#wsdl.endpoint(asynchronousbpelprocess_client_ep/AsynchronousBPELProcessCallback_pt)"/>
    </callback>
  </service>

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 as I mentioned in previous post also. See previous Post Step 1 for details steps.

New OSB Project

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.
Call Back Proxy Creation
  • Choose AsynchronousBPELProcessCallBackDirectBinding1.2 from Bindings and click Submit. Then click on Next button.
                          choose call back direct binding
  • Choose “sb” protocol and click next.

choose sb protocol
  • Accept default values and we have call back proxy service ready. Now we can move to Business service creation.
Call Back proxy service

Step 3: In this step we will create Business Service based on Asynchronous web service WSDL file.
  •       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.
Business Service Creation
  •      Select “AsynchronousBPELProcessDirectBinding1.2” from WSDL definitions. Click Submit and then go to Next step.
choose direct binding for business service
  •      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.
                            add endpoints
  •      Select “Asynchronous client” as Role. Then browse for Call Back proxy service and choose previously created Call Back proxy service.
choose call back proxy
  •      Accept Default values and you are ready with Business service.
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.
Message Flow
  •      Add Route Activity to proxy service flow to call Business Service. You can edit the name of the route activity.
add route node
  •     Now Go to Edit Route.
edit route node
  •      Add a new Action “Routing” inside Route Node.
add routing action
  •      Choose Business Service. And choose operation for the Business Service.
call 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.

Go through my previous Post




5 comments :

  1. hi Vivek,

    Thanks for the post, this was really helpful. But, we have a requirement to call an external Async wsdl (with http transport). Can you please advice how can we configure the CallBack client details when the transport is 'http'

    Regards,
    Krishna

    ReplyDelete
  2. Krishna,

    To call Async wsdl from OSB we need to use soa-direct protocol. Till now I don't know any way to configure CallBack client for Async Wsdl with http protocol. I will get back to you if I get it working.

    Regards,
    Vivek

    ReplyDelete
  3. Krishna,

    I created a new post to explain how we can call Async web service from OSB over http protocol.

    http://soawork.blogspot.in/2012/12/call-asynchronous-webservice-from-osb-over-http.html

    Regards,
    Vivek

    ReplyDelete
  4. If you follow all the steps then it should work but if you are still facing any issue then please send me your code, I will look into it.

    Vivek

    ReplyDelete
  5. How can I get the status of Callback proxy in my response in OSB ???

    ReplyDelete