Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop web services - Addressing (WS-Addressing) > Use the IBM proprietary Web Services Addressing SPIs: Performing more advanced Web Services Addressing tasks


Specify and acquiring message-addressing properties by using the IBM proprietary Web Services Addressing SPIs

Use the proprietary Web Services Addressing (WS-Addressing) system programming interfaces (SPIs), you can add WS-Addressing message addressing properties (MAPs) to the SOAP headers of an outbound client message, through properties on the JAX-WS BindingProvider request context, or the JAX-RPC Stub or Call object. When the target endpoint receives the message, the SPI enables the endpoint to acquire the MAPs through properties on the message context.

There are no equivalent SPIs in the JAX-WS standard. If to set message-addressing properties in a client that uses JAX-WS endpoint references, convert the endpoint references to the IBM proprietary classes, before using them with these SPIs.

Complete this task if you are a web service developer that uses the WS-Addressing support, or a system programmer that uses the IBM proprietary WS-Addressing SPIs to specify message addressing properties, such as fault or reply endpoint references, on web services messages.

The properties that you can set or retrieve are described, with the Java type of property instances, in IBM proprietary Web Services Addressing SPIs. Most properties are of type com.ibm.websphere.wsaddressing.EndpointReference, for example destination, reply, or fault endpoint references. The relationship property is a java.util.Set object that contains instances of the com.ibm.wsspi.wsaddressing.Relationship class. Use relationships when to specify an association between messages; for example, in a response message you might want to specify the ID of the message to which you are replying. The action property is an AttributedURI object that identifies a specific method or operation within the target endpoint.

Attention: The destination endpoint reference and action properties are required for the message to be WS-Addressing compliant.


Procedure

  1. On the client, obtain the endpoint reference from the service and associate it with your BindingProvider object request context, or your Stub or Call object, as described in Create a JAX-RPC web service application that uses Web Services Addressing.

  2. Create instances of the required properties. For example, to specify an endpoint reference for the target service to send replies to, create an instance of the com.ibm.websphere.wsaddressing.EndpointReference class, to use as the WSADDRESSING_REPLYTO_EPR property.

  3. Set the required properties by associating them with the BindingProvider object request context, or the Stub or Call object. If you are using a Stub or Call object, use the setProperty(String property_name, Object value) method. Note that unlike the endpoint reference required for the first step, these endpoint references do not have to be converted to another type, because they are passed in the header of the SOAP message rather than the body. The following example sets a destination endpoint reference and a reply endpoint reference on a BindingProvider object request context:
    import javax.xml.ws.BindingProvider;
    ...
     javax.xml.ws.Service jaxwsServiceObject=...;
     Printer myPrinterProxy = jaxwsServiceObject.getPort(portName, Printer.class);
    
     javax.xml.ws.BindingProvider myBindingProvider = (javax.xml.ws.BindingProvider)myPrinterProxy;
    
     // Retrieve the request context for the BindingProvider object  Map myMap = myBindingProvider.getRequestContext();
    
     // Associate the endpoint reference for the web service. This property is required for the message
     // to be WS-Addressing compliant.
      myMap.put(WSADDRESSING_DESTINATION_EPR, destinationEpr);
    
     // Associate the endpoint reference that represents the reply to the request context  myMap.put(WSADDRESSING_REPLYTO_EPR, replyToEpr);
    
    
    When an invocation occurs on the BindingProvider, Stub, or Call object, the product adds the appropriate MAPs to the message header.

  4. On the server, retrieve the MAPs from the inbound message through the javax.xml.ws.WebServiceContext or javax.xml.rpc.handler.MessageContext object that is currently on the thread. When WAS receives the message, it puts the MAP information into the message context on the thread, making it available to the service. We can retrieve the message context by, for example, using the session context of the endpoint enterprise bean. For more information about message contexts, refer to the JSR-109 standard. The following example retrieves the reply endpoint reference by using the web service context:
    import javax.xml.ws.handler.MessageContext;
    import javax.xml.ws.WebServiceContext;
    ...
    
      // Obtain the message context from the WebService context
      private WebServiceContext wsContext;
      MessageContext context = wsContext.getMessageContext();
    
      // Retrieve the reply endpoint reference
      replyToEpr = context.getProperty(WSADDRESSING_INBOUND_REPLYTO_EPR);
    
    


IBM proprietary Web Services Addressing SPIs
Use the IBM proprietary Web Services Addressing SPIs: Performing more advanced Web Services Addressing tasks

+

Search Tips   |   Advanced Search