Interoperate with Web Services Addressing endpoints that do not support the default specification supported by WebSphere Application Server
A target web service endpoint might not support the same Web Services Addressing (WS-Addressing) namespace as this product. In most cases, we do not have to undertake any extra actions to interoperate with such endpoints, however some scenarios require additional steps in the implementation of our web service.
WebSphere Application Server supports the default WS-Addressing 2005/08 namespace http://www.w3.org/2005/08/addressing. Complete this task to interoperate with endpoints that support other namespaces. This task specifically describes interoperation with endpoints that are hosted on a node that supports only the 2004/08 namespace: http://schemas.xmlsoap.org/ws/2004/08/addressing.
If we are using the standard JAX-WS API, ensure that we use the appropriate feature, annotation or endpoint reference class for the 2004/08 namespace.
If we are sending to or receiving messages from an endpoint that supports only the 2004/08 namespace, we do not have to undertake any additional steps for interoperability. This product recognizes and understands incoming WS-Addressing messages that conform to the 2004/08 specification, and outbound messages automatically adhere to the namespace of their destination endpoint reference. If we are sending a request, all WS-Addressing elements, such as reply endpoint or fault endpoint elements, must use the same namespace as the message. Any discrepancy results in a JAX-WS or JAX-RPC configuration error.
If we are interacting in a different way with an endpoint that supports only the 2004/08 namespace, such as exporting endpoint references in the message header or body, and we are not using the JAX-WS standard API, we must undertake additional steps as detailed later in this topic.
Tasks
- If we are generating a web service for use by a client that supports only the 2004/08 specification, update the WS-Addressing namespace in the Web Services Description Language (WSDL) document for our web service, by changing http://www.w3.org/2006/05/addressing/wsdl to http://schemas.xmlsoap.org/ws/2004/08/addressing.
Only the WS-Addressing WSDL Action extensibility element is recognized by pre-W3C WS-Addressing clients.
- If we are creating endpoint references at run time for export to an endpoint that supports the 2004/08 namespace only, perform the following steps:
- Create the endpoint reference to export.
- Associate the appropriate namespace with the endpoint reference, using the setNamespace method. The following example illustrates the association of the 2004/08 namespace with an endpoint reference:
import com.ibm.wsspi.wsaddressing.EndpointReference; import com.ibm.wsspi.wsaddressing.NamespaceNotSupportedException; import com.ibm.wsspi.wsaddressing.WSAConstants; : EndpointReference epr = ... try { epr.setNamespace(WSAConstants.WSADDRESSING_NAMESPACE_2004_08); } catch (NamespaceNotSupportedException e) { // Error handling code here }When we pass the endpoint reference to the target endpoint, in either the SOAP body or the SOAP header of a message, the endpoint reference is appropriately serialized into SOAP elements according to its namespace.
- To establish the namespace of an inbound request, use the IBM proprietary WS-Addressing system programming interface (SPI) to retrieve the WSADDRESSING_INBOUND_NAMESPACE property from the inbound message context. This property specifies the Core WS-Addressing specification namespace of the incoming message.
This procedure uses the IBM proprietary WS-Addressing API. There is no equivalent procedure in the JAX-WS API.
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 specification. The following code example shows how we can establish the namespace of an incoming message on the receiving endpoint:
import com.ibm.wsspi.wsaddressing.WSAConstants; import javax.xml.rpc.handler.MessageContext; : // If the endpoint is implemented as an enterprise bean, we can use its session context // to obtain the message context private SessionContext sessionContext; MessageContext context = sessionContext.getMessageContext(); try { String namespace = (String)msgContext.getProperty(WSAConstants.WSADDRESSING_INBOUND_NAMESPACE); } catch (IllegalArgumentException e) { // Error handling code here }
Related:
Web Services Resource Framework support Web Services Addressing APIs IBM proprietary Web Services Addressing SPIs Create stateful web services using the Web Services Resource Framework JSR-109 specification