JMS based Web Services in Oracle App Server Part 1: WCF Interoperability

By Jesus Rodriguez

This is the first of two articles intended to illustrate Java Messaging Service (JMS)-based Web Services using Oracle Application Server. Specifically, this article focuses on how to achieve JMS .NET interoperability through JMS-based Web Services.

Java Messaging Service (JMS) is one of the key components of the J2EE model. Nowadays there are thousands of applications built on top of the different JMS implementations available. However, JMS still remains an almost exclusive technology of the J2EE stack, commonly obscure to .NET developers. That, among other factors, creates an interesting and always challenging endeavor with JMS .NET interoperability.

The emergence of Web Services technologies has brought new alternatives to achieve JMS-.NET interoperability. Assembling Web Services endpoints on top of JMS artifacts, like destinations, connections, etc., allows interaction with those artifacts from non J2EE environments like .NET.

Among the existing J2EE Web Services technologies, Oracle Application Server extensively leverages the rich JMS feature set. Oracle Application Server allows you to assemble Web Services on top of native JMS destinations like queues or topics. That functionally allows abstracting JMS native concepts behind a Web Services contract mainly composed of basic operations like Send and Receive. Additionally, the Web Services can rely on low-level, one-way JMS send-receive operations to implement more complex message exchange patterns like Request-Response.

An Oracle JMS endpoint Web service can have the following operations.

·         Send: the XML payload (SOAP body element) is sent to the corresponding JMS destination. A send operation can be configured so that JMS message properties can be set on each sent message to indicate the JMS reply-to destination, priority, expiration, and so on.

·         Receive: a message is retrieved from the corresponding JMS destination, the content of the JMS message is used to create the SOAP response message body payload.

·         Both: a service can offer both operations.

The great benefit of this approach is that it is provided as part of the platform. In other words, it standardizes the way JMS endpoints are exposed as Web Services using common contracts and tools. The following section will explore the steps required to assemble a Web Service from a set of JMS destinations.

Implementing a JMS based Web Services in Oracle App Server

For purposes of this example we will use a JMS queue named demoQueue.

·         Once the JMS destination is available we can create a new JMS Web Service following the JDeveloper project template with the same name.

·         Next, we need to implement the Send operation and bind it to the correct JMS destination.

 

Figure1: Web Service Send Request: JMS binding configuration

  

·         In case of request-response operations the JMS destination used for the reply message must also specified.

   

 

Figure2: Web Service Send Response: JMS binding configuration

  

·         Similar steps have to be followed for the Receive operation.

 

Figure 3: Web Service Receive Request: JMS binding configuration

The following figure shows the WSDL generated after completing the previous steps.

<definitions

          name="MyWebService1"

          targetNamespace="http://jmsservices/MyWebService1.wsdl"

          xmlns="http://schemas.xmlsoap.org/wsdl/"

          xmlns:tns="http://jmsservices/MyWebService1.wsdl"

          xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"

          xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"

          xmlns:tns0="http://jmsservices/MyWebService1.wsdl/types/"

          xmlns:xsd="http://www.w3.org/2001/XMLSchema"

          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

        >

            <types>

                        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://jmsservices/MyWebService1.wsdl/types/"

                          elementFormDefault="qualified" xmlns:tns="http://jmsservices/MyWebService1.wsdl/types/"

                          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                          xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/">

                                    <element name="receiveElement">

                                                <complexType>

                                                            <sequence/>

                                                </complexType>

                                    </element>

                                    <element name="receiveResponseElement">

                                                <complexType>

                                                            <sequence>

                                                                        <element name="result" nillable="true">

                                                                                    <complexType>

                                                                                                <sequence>

                                                                                                            <any/>

                                                                                                </sequence>

                                                                                    </complexType>

                                                                        </element>

                                                            </sequence>

                                                </complexType>

                                    </element>

                                    <element name="sendElement">

                                                <complexType>

                                                            <sequence>

                                                                        <element name="input" nillable="true">

                                                                                    <complexType>

                                                                                                <sequence>

                                                                                                            <any/>

                                                                                                </sequence>

                                                                                    </complexType>

                                                                        </element>

                                                            </sequence>

                                                </complexType>

                                    </element>

                                    <element name="sendResponseElement">

                                                <complexType>

                                                            <sequence/>

                                                </complexType>

                                    </element>

                        </schema>

            </types>

            <message name="JmsDestination_receive">

                        <part name="parameters" element="tns0:receiveElement"/>

            </message>

            <message name="JmsDestination_receiveResponse">

                        <part name="parameters" element="tns0:receiveResponseElement"/>

            </message>

            <message name="JmsDestination_send">

                        <part name="parameters" element="tns0:sendElement"/>

            </message>

            <message name="JmsDestination_sendResponse">

                        <part name="parameters" element="tns0:sendResponseElement"/>

            </message>

            <portType name="JmsDestination">

                        <operation name="receive">

                                    <input message="tns:JmsDestination_receive"/>

                                    <output message="tns:JmsDestination_receiveResponse"/>

                        </operation>

                        <operation name="send">

                                    <input message="tns:JmsDestination_send"/>

                                    <output message="tns:JmsDestination_sendResponse"/>

                        </operation>

            </portType>

            <binding name="MyWebService1SoapHttp" type="tns:JmsDestination">

                        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

                        <operation name="receive">

                                    <soap:operation soapAction="http://jmsservices/MyWebService1.wsdl/receive"/>

                                    <input>

                                                <soap:body use="literal"/>

                                    </input>

                                    <output>

                                                <soap:body use="literal"/>

                                    </output>

                        </operation>

                        <operation name="send">

                                    <soap:operation soapAction="http://jmsservices/MyWebService1.wsdl/send"/>

                                    <input>

                                                <soap:body use="literal"/>

                                    </input>

                                    <output>

                                                <soap:body use="literal"/>

                                    </output>

                        </operation>

            </binding>

            <service name="MyWebService1">

                        <port name="MyWebService1SoapHttpPort" binding="tns:MyWebService1SoapHttp">

                                    <soap:address location="http://MyServer/WSInterop-JMSServices-context-root/MyWebService1SoapHttpPort"/>

                        </port>

            </service>

</definitions>

  

  

This example allows you to send and receive arbitrary xml messages. In order to create fully typed contracts we should use the Java binding capabilities exposed on the wizard.

Implementing a JMS WCF client

The abstractions created in Oracle make the creation of a JMS .NET client no different from any other WS-I compliant Web Service. For the purpose of this example we use a WCF client as illustrated in the following code.

JMSServices.JmsDestinationClient proxy = new      JMSClient.JMSServices.JmsDestinationClient();

XmlDocument msgDoc = new XmlDocument();

msgDoc.LoadXml("<msg>JMS .NET message</msg>");

proxy.send(msgDoc.DocumentElement);

 After executing the above code the message is delivered to JMSDemoQueue.

Either basicHttpBinding or wsHttpBinding can be used to achieve the communication with the Oracle Web Service.

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

        <system.serviceModel>

                <bindings>

                        <basicHttpBinding>

                                <binding name="JMSDestServiceSoapHttp">

                                        <security mode="None">

                                                <transport clientCredentialType="None" proxyCredentialType="None"

                                                        realm="" />

                                                <message clientCredentialType="UserName" algorithmSuite="Default" />

                                        </security>

                                </binding>

                        </basicHttpBinding>

                </bindings>

                <client>

                        <endpoint address="http://oracleappserver/WSInterop-JMSServices-context-root/JMSDestServiceSoapHttpPort"

                                binding="basicHttpBinding" bindingConfiguration="JMSDestServiceSoapHttp"

                                contract="JMSClient.JMSServices.JmsDestination" name="JMSDestServiceSoapHttpPort" />

                </client>

        </system.serviceModel>

</configuration>

  

Summary

This article has explained how to achieve JMS .NET interoperability exposing JMS destinations as Oracle Web Services. Oracle Application Server provides the mechanism to create WS-I compatible Web Services based on JMS destinations. This process facilitates the creation.NET clients that follow Standard SOAP-based interaction with the JMS destinations. The next article will explore how to use JMS as a transport for persistent communication with Oracle App Server Web Services.

No Comments