Search

Chapter 4.  WS Addressing

download PDF
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>
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.