Building an asynchronous web service with OSB

Bookmark and Share
A few weeks ago I made a blogpost over how you can build an asynchronous web service with JAX-WS. In this blogpost I will do the same in the Oracle Service Bus. What you probably already know is that OSB Proxy Service does not support asynchronous calls. This does not mean that it is impossible to do asynchronous calls in the OSB.  To make this work I have the following setup.

A HTTP Proxy Service  -> JMS Business Service -> Queue -> JMS Proxy Service -> HTTP Business Service.



I start with the WSDL which has two operations execute and callback.

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:inp1="http://xmlns.oracle.com/singleString" xmlns:tns="http://xmlns.oracle.com/AsyncEmployeeService" xmlns:emp="http://employee" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="AsyncEmployeeService" targetNamespace="http://xmlns.oracle.com/AsyncEmployeeService">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://employee" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://employee" elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:element name="Employee" type="Emp"/>
<xs:element name="EmployeeResponse" type="xs:string"/>
<xs:complexType name="Emp">
<xs:sequence>
<xs:element name="empno" type="xs:int"/>
<xs:element name="ename" type="xs:string"/>
<xs:element name="job" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="callbackMessage">
<wsdl:part name="callback" element="emp:EmployeeResponse"/>
</wsdl:message>
<wsdl:message name="requestMessage">
<wsdl:part name="request" element="emp:Employee"/>
</wsdl:message>
<wsdl:portType name="callback_ptt">
<wsdl:operation name="callback">
<wsdl:input message="tns:callbackMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="execute_ptt">
<wsdl:operation name="execute">
<wsdl:input message="tns:requestMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="execute_pttBinding" type="tns:execute_ptt">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="execute">
<soap:operation soapAction="execute" style="document"/>
<wsdl:input>
<soap:body use="literal" namespace="http://xmlns.oracle.com/AsyncEmployeeService"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="callback_pttBinding" type="tns:callback_ptt">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="callback">
<soap:operation soapAction="callback" style="document"/>
<wsdl:input>
<soap:body use="literal" namespace="http://xmlns.oracle.com/AsyncEmployeeService"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
The execute operation is used in the HTTP Proxy Service and the callback operation in the HTTP Business Service. The HTTP Proxy Service does the following:

  • retrieves the Addressing MessageID from the header, $header/wsa05:MessageID/text() , In this case you need to use the 2005 / 08 addressing.
  • retrieves the Addressing Reply URL from the header, $header/wsa05:ReplyTo/wsa05:Address/text(). This URL will be used in the callback HTTP Business Service
  • Make a new Body for the Queue which contains the WS Request and the Reply URL
  • Set the JMS CorrelationID with MessageID as value, use the Transport Header activity
  • Call the JMS Business Service.   
The JMS Business Service put the Message on a Queue.



The JMS Queue has the following exception properties, these settings are very important else you can create a loop when something goes wrong, with these settings the message will be moved to the error queue when the dequeue proxy service fails twice.

The JMS Dequeue Proxy Service steps:



  • Dequeue the JMS Message
  • Retrieves the Addressing MessageID from the JMS header, $inbound/ctx:transport/ctx:request/tp:headers/jms:JMSCorrelationID/text()
  • Retrieves the ReplyURL from the body
  • Replace the header with this one <wsa05:RelatesTo>{$messageId}</wsa05:RelatesTo>
  • Set the URL with the ReplyURL value, set the URL in the Routing Options activity.
  • Call the HTTP Business Service.
The HTTP Business Service has a dummy url and uses the callback operation from the WSDL.



Deploy everything to the OSB Server and start SOAPUI so you can test this OSB project.



In SOAPUI you can import the WSDL of the HTTP Proxy Service. I will use the execute operation as test and  make a mock service based on the callback operation.

Start the mockservice and remember the url of this mock service

Create a request and enable WS-Adressing, put the mockservice url in the Reply To field and enable Randomly generate MessageId

The OSB will call your mock service with the response and uses RelatesTo element which contains the MessageId of the request.

{ 0 comments... Views All / Send Comment! }

Post a Comment