Specifying and acquiring message addressing properties using the Web Services Addressing SPI

The Web Services Addressing (WS-Addressing) system programming interface (SPI) enables you to add WS-Addressing message addressing properties (MAPs) to the SOAP headers of an outbound 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.

About this task

Perform this task if you are a Web service developer using the WS-Addressing support, or a system programmer using the 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 detailed, with the Java type of property instances, in Web Services Addressing SPI. 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 you 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 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's request context, or your Stub or Call object, as described in Creating a Web service application that is referenced through a Web Services Addressing endpoint reference.
  2. Create instances of the required properties. For example, if you want 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's 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 need 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's request context:
    import javax.xml.ws.BindingProvider;
    ...
     // Associate the endpoint reference for the Web service. This property is required for the message 
     // to be WS-Addressing compliant.
     Map myMap = myBindingProvider.getRequestContext();
     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, WebSphere Application Server 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. You 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);
    



In this information ...


Related reference

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 1:23:07 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-dist&topic=twbs_wsa_maps
File name: twbs_wsa_maps.html