WAS v8.5 > Develop 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 using the IBM proprietary Web Services Addressing SPIs

Using the proprietary Web Services Addressing (WS-Addressing) system programming interfaces (SPIs), we 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. To set message-addressing properties in a client that uses JAX-WS endpoint references, you must 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 we 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 containing instances of the com.ibm.wsspi.wsaddressing.Relationship class. Use relationships when we want to specify an association between messages; for example, in a response message you might want to specify the ID of the message to which we are replying. The action property is an AttributedURI object that identifies a specific method or operation within the target endpoint.

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

  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 we 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. 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 WebSphere Application Server 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 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);


Related concepts:

IBM proprietary Web Services Addressing SPIs


+

Search Tips   |   Advanced Search