13.5. JAX-WS Development Reference

13.5.1. Enable Web Services Addressing (WS-Addressing)


  • Your application must have an existing JAX-WS service and client configuration.

Procedure 13.1. Annotate and Update client code

  1. Annotate the service endpoint

    Add the @Addressing annotation to the application's endpoint code.

    Example 13.28. @Addressing annotation

    This example demonstrates a regular JAX-WS endpoint with the @Addressing annotation added.
    package org.jboss.test.ws.jaxws.samples.wsa;
    import javax.jws.WebService;
    import javax.xml.ws.soap.Addressing;
       portName = "AddressingServicePort",
       serviceName = "AddressingService",
       wsdlLocation = "WEB-INF/wsdl/AddressingService.wsdl",
       targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsaddressing",
       endpointInterface = "org.jboss.test.ws.jaxws.samples.wsa.ServiceIface"
    @Addressing(enabled=true, required=true)
    public class ServiceImpl implements ServiceIface
       public String sayHello()
          return "Hello World!";
  2. Update client code

    Update the client code in the application so that it configures WS-Addressing.

    Example 13.29. Client configuration for WS-Addressing

    This example demonstrates a regular JAX-WS client updated to configure WS-Addressing.
    package org.jboss.test.ws.jaxws.samples.wsa;
    import java.net.URL;
    import javax.xml.namespace.QName;
    import javax.xml.ws.Service;
    import javax.xml.ws.soap.AddressingFeature;
    public final class AddressingTestCase
       private final String serviceURL = 
       public static void main(String[] args) throws Exception
          // construct proxy
          QName serviceName = 
              new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing",
          URL wsdlURL = new URL(serviceURL + "?wsdl");
          Service service = Service.create(wsdlURL, serviceName);
          ServiceIface proxy = 
                                            new AddressingFeature());
          // invoke method

The client and endpoint are now communicating using WS-Addressing.