Chapter 4. WS Addressing
CXF provides support for the 2004-08 and 1.0 versions of WS-Addressing. Users can enable WS-Addressing either using the standard JAX-WS approach or using the Apache CXF WS Addressing Feature on their service.
4.1. Using JAX-WS for enabling WS-Addressing
As per JAX-WS 2.1 specification, users can enable WS-Addressing on a web service endpoint by simply adding the @javax.xml.soap.Addressing annotation.
package org.jboss.test.ws.jaxws.samples.wsa; import javax.jws.WebService; import javax.xml.ws.soap.Addressing; @WebService @Addressing(enabled=true, required=true) public class ServiceImpl implements ServiceIface { public String sayHello() { return "Hello World!"; } }
On the client side, WS-Addressing can be explicitly enabled by providing
org.apache.cxf.ws.addressing.WSAddressingFeature
when getting the proxy instance from the service:
ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class, new AddressingFeature()); proxy.sayHello());
4.1.1. Using CXF proprietary WSAddressingFeature
To enable WS-Addressing, enable the WSAddressingFeature on your service. If you wish to use XML to configure this, use the following syntax:
<jaxws:endpoint id="{your.service.namespace}YourPortName"> <jaxws:features> <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/> </jaxws:features> </jaxws:endpoint>
You can also use the same exact syntax with a <jaxws:client>:
<jaxws:client id="{your.service.namespace}YourPortName"> <jaxws:features> <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing"/> </jaxws:features> </jaxws:client>