JBoss Community Archive (Read Only)

WildFly 8


JBoss Web Services inherits full WS-Addressing capabilities from the underlying Apache CXF implementation. Apache CXF provides support for 2004-08 and 1.0 versions of WS-Addressing.

Enabling WS-Addressing

WS-Addressing can be turned on in multiple standard ways:

  • consuming a WSDL contract that specifies a WS-Addressing assertion / policy

  • using the @javax.xml.ws.soap.Addressing annotation

  • using the javax.xml.ws.soap.AddressingFeature feature

The supported addressing policy elements are:


Alternatively, Apache CXF proprietary ways are also available:

  • specifying the [http://cxf.apache.org/ws/addressing]addressing feature for a given client/endpoint in an optional CXF Spring XML descriptor

  • using the org.apache.cxf.ws.addressing.WSAddressingFeature feature through the API

  • manually configuring the Apache CXF addressing interceptors (org.apache.cxf.ws.addressing.MAPAggregator and org.apache.cxf.ws.addressing.soap.MAPCodec)

  • setting the org.apache.cxf.ws.addressing.using property in the message context

Please refer to the the Apache CXF documentation for further information on the proprietary WS-Addressing setup and configuration details.

Addressing Policy

The WS-Addressing support is also perfectly integrated with the Apache CXF WS-Policy engine.

This basically means that the WSDL contract generation for code-first endpoint deployment is policy-aware: users can annotate endpoints with the @javax.xml.ws.soap.Addressing annotation and expect the published WSDL contract to contain proper WS-Addressing policy (assuming no wsdlLocation is specified in the endpoint's @WebService annotation).

Similarly, on client side users do not need to manually specify the javax.xml.ws.soap.AddressingFeature feature, as the policy engine is able to properly process the WS-Addressing policy in the consumed WSDL and turn on addressing as requested.


Here is an example showing how to simply enable WS-Addressing through WS-Policy.


A simple JAX-WS endpoint is prepared using a java-first approach; WS-Addressing is enforced through @Addressing annotation and no wsdlLocation is provided in @WebService:

package org.jboss.test.ws.jaxws.samples.wsa;

import javax.jws.WebService;
import javax.xml.ws.soap.Addressing;
import org.jboss.logging.Logger;

   portName = "AddressingServicePort",
   serviceName = "AddressingService",
   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
   private Logger log = Logger.getLogger(this.getClass());

   public String sayHello(String name)
      return "Hello " + name + "!";

The WSDL contract that's generated at deploy time and published looks like this:

<wsdl:definitions ....>
  <wsdl:binding name="AddressingServiceSoapBinding" type="tns:ServiceIface">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsaw:UsingAddressing wsdl:required="true"/>
    <wsp:PolicyReference URI="#AddressingServiceSoapBinding_WSAM_Addressing_Policy"/>

    <wsdl:operation name="sayHello">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="sayHello">
        <soap:body use="literal"/>
      <wsdl:output name="sayHelloResponse">
        <soap:body use="literal"/>

  <wsdl:service name="AddressingService">
    <wsdl:port binding="tns:AddressingServiceSoapBinding" name="AddressingServicePort">
      <soap:address location="http://localhost:8080/jaxws-samples-wsa"/>
    <wsp:Policy wsu:Id="AddressingServiceSoapBinding_WSAM_Addressing_Policy"
      <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">


Since the WS-Policy engine is on by default, the client side code is basically a pure JAX-WS client app:

QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
URL wsdlURL = new URL("http://localhost:8080/jaxws-samples-wsa?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 13:48:11 UTC, last content change 2012-02-15 13:57:41 UTC.