Skip to main content

OSB 11g Asynchronous SOA service from OSB By soa-direct protocol

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.



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

  • 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.
  •  Now Go to Edit Route.

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












      Comments

      1. Hey,
        I 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.

        ReplyDelete
        Replies
        1. 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.

          Delete
      2. Sample SOA & OSB code is available in google drive.

        https://drive.google.com/file/d/0BzvVcpM2dprBbFZOSGpkMkJpUlE/view?usp=sharing

        ReplyDelete
      3. Received a query over linkedin:

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

        ReplyDelete
      4. But in the blog of making async service a sync service in osb we used a jms

        ReplyDelete
      5. Thanks for the post, perhaps you have this in osb 12c and soa 12c ?

        ReplyDelete

      Post a Comment

      Popular posts from this blog

      Solution for BPM standard dashboard & activity guide not working in Oracle SOA 12.2.1.0 C

      As earlier i publish a post about different issue of Oracle BPM, After some oracle support i got to fixed them. Issue Blog Here... Issue 3:BPM 12.2.1 process workspace activity guide not working. if you have a normal BPM Process, then this is the issue. In order to have data populated in "Activity Guide" firstly you should create a BPMN Guided Business Process. Below you can find the documentation about activity guide and how to create a Guided Business Process: https://docs.oracle.com/middleware/1221/bpm/bpm-develop/GUID-F765955D-90A5-48D4-8D2A-2F01FBB539E3.htm#BPMPD901 And here is specified: " A Guided Business Process is modeled as an activity guide that is based on a business process. The Activity Guide includes a set of Milestones. A milestone is a contained set of tasks that the end user has to complete. A milestone is complete when the user successfully runs a specific set of tasks in the milestone. " And in the below chapters you will find the ...

      Oracle SOA 12C rest adapter with Custom HTTP headers

      Most existing web applications are connected through web services, which are commonly known as SOAP services. More and more users are relying on mobile devices for communication, and they’re looking for lighter ways to access enterprise information on the go. REST services are the answer for the mobile device platform, because they get rapid responses and fast access to data. Oracle SOA Suite 12 c  provides a complete set of service infrastructure components for designing, deploying, and managing composite applications. Oracle SOA Suite 12 c  enables services to be created, managed, and orchestrated into composite applications and business processes. Some time we have need to send HTTP headers in REST service, In OSB we use header component and add what ever is needed but in oracle SOA 12C it's little bit different. Let see how we can do it. Create one SOA Application. Create one SOA Sample project inside SOA Application. Go to composite and drag drop REST ...

      Swagger API document from Any WADL & Schema in Oracle SOA

      Hi everyone, Hope everyone is doing well these days, Recently i started a project work over how to generate swagger API document for your any REST API, In case if you don't know what is swagger please go and check " https://swagger.io/tools/swagger-editor/ ". It's a great and easy to use tool which will help to create user friendly, human readable form API documentation with extension for generating API client in different languages with capability of testing your API from same. What is swagger editor, Design, describe, and document your API on the first open source editor fully dedicated to OpenAPI-based APIs. The Swagger Editor is great for quickly getting started with the OpenAPI (formerly known as the Swagger Specification) specification, with support for Swagger 2.0 and OpenAPI 3.0.  What benefits you will get by using swagger, Runs Anywhere, The Editor works in any development environment, be it locally or in the web. Smart Feedback, Validate you...