+

Search Tips   |   Advanced Search

Writing the WSDL extensions that let the WSIF service access a service at a JMS destination

Use the native Java Message Service (JMS) provider, Web Services Invocation Framework (WSIF) clients can treat a service available at a JMS destination as a Web service. Use this information, and associated code fragments, to help you to write the WSDL extensions.

This topic assumes that we chose and configured a JMS provider when we installed WebSphere Application Server (either the default messaging provider, or another provider such as the IBM MQ messaging provider). If not, do so now as described in Choose a messaging provider.

The WSDL extensions for JMS are identified with the namespace prefix jms. For example, <jms:binding>.

The supported operations are either one-way operations (send for JMS point-to-point messaging, or publish for JMS publish and subscribe messaging) or request-response operations (send and receive for JMS point-to-point messaging). The WSDL operations therefore specify either an input message only, or an input and an output message.

Operations that describe message interfaces with a native JMS binding do not have fault messages. No assumptions are made about the message schema or the semantics of message properties, therefore no distinction can be made between output and fault messages.

Use the following procedure, and associated code fragments, to help you to write the WSDL extensions that enable the WSIF service to access an underlying service at a JMS destination.


Tasks


Example 1: JMS Text Message

The JMS text message contains a java.lang.String. In this example, the WSDL message contains only one part that represents the whole message body:

<wsdl:definitions ... > 

   <!-- simple or complex types for input and output message -->
   <wsdl:types> ... </wsdl:types>
   
   <wsdl:message name="JmsOperationRequest"> ... </wsdl:message>
   <wsdl:message name="JmsOperationResponse"> ... </wsdl:message>
 
   <wsdl:portType name="JmsPortType">
      <wsdl:operation name="JmsOperation">
         <wsdl:input name="Request" 
                     message="tns:JmsOperationRequest"/>
         <wsdl:output name="Response" 
                      message="tns:JmsOperationResponse"/>
      </wsdl:operation>
   </wsdl:portType>

   <wsdl:binding name="JmsBinding" type="JmsPortType">
      <jms:binding type="TextMessage" />

      <format:typemapping style="Java" encoding="Java">           
         <format:typemap name="xsd:String" formatType="String" />
      </format:typemapping>

      <wsdl:operation name="JmsOperation">
         <wsdl:input message="JmsOperationRequest">
            <jms:input parts="requestMessageBody" />
         </wsdl:input>
         <wsdl:output message="JmsOperationResponse">
            <jms:output parts="responseMessageBody" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>

   <wsdl:service name="JmsService">
      <wsdl:port name="JmsPort" binding="JmsBinding">
         <jms:address destinationStyle="queue" 
                      jndiConnectionFactoryName="myQCF" 
                      jndiDestinationName="myDestination"/>
      </wsdl:port>
   </wsdl:service>

</wsdl:definitions>

As an extension to the previous JMS message example, the following example WSDL describes a request-response operation in which specific JMS property values of the request and response message are set for the request message and retrieved from the response message.

The JMS properties in the request message are set according to the values in the input message. Likewise, selected JMS properties of the response message are copied to the corresponding values of the output message. The direction of the mapping is determined by the appearance of the <jms:property> tag in the input or output section, respectively.

<wsdl:definitions ... > 

   <!-- simple or complex types for input and output message -->
   <wsdl:types> ... </wsdl:types>
   
   <wsdl:message name="JmsOperationRequest"> 
      <wsdl:part name="myInt" type="xsd:int"/>
      ...
   </wsdl:message>

   <wsdl:message name="JmsOperationResponse"> 
      <wsdl:part name="myString" type="xsd:String"/>
      ... 
   </wsdl:message>
 
   <wsdl:portType name="JmsPortType">
      <wsdl:operation name="JmsOperation">
         <wsdl:input name="Request" 
                     message="tns:JmsOperationRequest"/>
         <wsdl:output name="Response" 
                      message="tns:JmsOperationResponse"/>
      </wsdl:operation>
   </wsdl:portType>

   <wsdl:binding name="JmsBinding" type="JmsPortType">
      <!-- the JMS message type might be any of the preceding types -->
      <jms:binding type="..." />

      <format:typemapping style="Java" encoding="Java">           
         <format:typemap name="xsd:int" formatType="int" />
         ...
      </format:typemapping>

      <wsdl:operation name="JmsOperation">
         <wsdl:input message="JmsOperationRequest">
            <jms:property message="tns:JmsOperationRequest" parts="myInt" />
            <jms:propertyValue name="myLiteralString" 
                          type="xsd:string" value="Hello World" />
            ...
         </wsdl:input>
         <wsdl:output message="JmsOperationResponse">
            <jms:property message="tns:JmsOperationResponse" parts="myString" />
            ...
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>

   <wsdl:service name="JmsService">
      <wsdl:port name="JmsPort" binding="JmsBinding">
         <jms:address destinationStyle="queue" 
                      jndiConnectionFactoryName="myQCF" 
                      jndiDestinationName="myDestination"/>
    </wsdl:port>
   </wsdl:service>

</wsdl:definitions>


Related:

  • WSIF and WSDL
  • Writing the WSDL extension that lets the WSIF service access a SOAP over JMS service
  • Enable a WSIF client to invoke a web service through JMS
  • JMS message header: The TimeToLive property reference