Skip to main content

Configuring an Endpoint

A JAX-WS Endpoint can be configured in XML in addition to using the JAX-WS APIs. Once you've created your Developing a Service using JAX-WS , you simply need to provide the class name and an address. Here is a simple example:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:jaxws="http://cxf.apache.org/jaxws"
   xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://cxf.apache.org/jaxws
      http://cxf.apache.org/schemas/jaxws.xsd">

<jaxws:endpoint id="classImpl"
   implementor="org.apache.cxf.jaxws.service.Hello"
   endpointName="e:HelloEndpointCustomized"
   serviceName="s:HelloServiceCustomized"
   address="http://localhost:8080/test"
   xmlns:e="http://service.jaxws.cxf.apache.org/endpoint"
   xmlns:s="http://service.jaxws.cxf.apache.org/service"/>

</beans>

Be sure to include the JAX-WS schemaLocation attribute specified on the root beans element. This allows CXF to validate the file and is required. Also note the namespace declarations at the end of the <jaxws:endpoint/> tag--these are required because the combined "{namespace}localName" syntax is presently not supported for this tag's attribute values.

The jaxws:endpoint element (which appears to create an EndpointImpl under the covers) supports many additional attributes:

Name

Value

endpointName

The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of "ns:ENDPOINT_NAME" where ns is a namespace prefix valid at this scope.

publish

Whether the endpoint should be published now, or whether it will be published at a later point.

serviceName

The service name this service is implementing, it maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope.

wsdlLocation

The location of the WSDL. Can be on the classpath, file system, or be hosted remotely.

bindingUri

The URI, or ID, of the message binding for the endpoint to use. For SOAP the binding URI(ID) is specified by the JAX-WS specification. For other message bindings the URI is the namespace of the WSDL extensions used to specify the binding.

address

The service publish address

bus

The bus name that will be used in the jaxws endpoint.

implementor

The implementor of jaxws endpoint. You can specify the implementor class name here, or just the ref bean name in the format of "#REF_BEAN_NAME"

implementorClass

The implementor class name, it is really useful when you specify the implementor with the ref bean which is wrapped by using Spring AOP

createdFromAPI

This indicates that the endpoint bean was already created using jaxws API's thus at runtime when parsing the bean spring can use these values rather than the default ones. It's important that when this is true, the "name" of the bean is set to the port name of the endpoint being created in the form "{http://service.target.namespace} PortName".

publishedEndpointUrl

The URL that is placed in the address element of the wsdl when the wsdl is retrieved. If not specified, the address listed above is used. This parameter allows setting the "public" URL that may not be the same as the URL the service is deployed on. (for example, the service is behind a proxy of some sort).

It also supports many child elements:

Name

Value

jaxws:executor

A Java executor which will be used for the service. This can be supplied using the Spring <bean class="MyExecutor"/> syntax.

jaxws:inInterceptors

The incoming interceptors for this endpoint. A list of <bean>s or <ref>s. Each should implement org.apache.cxf.interceptor.Interceptor or org.apache.cxf.phase.PhaseInterceptor

jaxws:inFaultInterceptors

The incoming fault interceptors for this endpoint. A list of <bean>s or <ref>s. Each should implement org.apache.cxf.interceptor.Interceptor or org.apache.cxf.phase.PhaseInterceptor

jaxws:outInterceptors

The outgoing interceptors for this endpoint. A list of <bean>s or <ref>s. Each should implement org.apache.cxf.interceptor.Interceptor or org.apache.cxf.phase.PhaseInterceptor

jaxws:outFaultInterceptors

The outgoing fault interceptors for this endpoint. A list of <bean>s or <ref>s. Each should implement org.apache.cxf.interceptor.Interceptor or org.apache.cxf.phase.PhaseInterceptor

jaxws:handlers

The JAX-WS handlers for this endpoint. A list of <bean>s or <ref>s. Each should implement javax.xml.ws.handler.Handler or javax.xml.ws.handler.soap.SOAPHandler (Note that @HandlerChain annotations on the service bean appear to be ignored)

jaxws:properties

A properties map which should be supplied to the JAX-WS endpoint. See below.

jaxws:dataBinding

Which DataBinding to use in the endpoint. This can be supplied using the Spring <bean class="MyDataBinding"/> syntax.

jaxws:binding

You can specify the BindingFactory for this endpoint to use. This can be supplied using the Spring <bean class="MyBindingFactory"/> syntax.

jaxws:features

The features that hold the interceptors for this endpoint. A list of <bean>s or <ref>s

jaxws:invoker

The invoker which will be supplied to this endpoint. This can be supplied using the Spring <bean class="MyInvoker"/> syntax.

jaxws:schemaLocations

The schema locations for endpoint to use. A list of <schemaLocation>s

jaxws:serviceFactory

The service factory for this endpoint to use. This can be supplied using the Spring <bean class="MyServiceFactory"/> syntax

Here is a more advanced example which shows how to provide interceptors and properties:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
   xmlns:soap="http://cxf.apache.org/bindings/soap"
   xsi:schemaLocation="
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://cxf.apache.org/bindings/soap 
      http://cxf.apache.org/schemas/configuration/soap.xsd
      http://cxf.apache.org/jaxws 
      http://cxf.apache.org/schemas/jaxws.xsd">

  <import resource="classpath:META-INF/cxf/cxf.xml"/>

  <jaxws:endpoint
     id="helloWorld"
     implementor="demo.spring.HelloWorldImpl"
     address="http://localhost/HelloWorld">
     <jaxws:inInterceptors>
        <bean class="com.acme.SomeInterceptor"/>
        <ref bean="anotherInterceptor"/>
     </jaxws:inInterceptor>
     <jaxws:properties>
        <entry key="mtom-enabled" value="true"/>
     </jaxws:properties>
  </jaxws:endpoint>

  <bean id="anotherInterceptor" class="com.acme.SomeInterceptor"/>

  <jaxws:endpoint id="simpleWithBinding"
     implementor="#greeter" 
     address="http://localhost:8080/simpleWithAddress">
     <jaxws:binding>
        <soap:soapBinding mtomEnabled="true" version="1.2"/>
     </jaxws:binding>
  </jaxws:endpoint>

  <jaxws:endpoint id="inlineInvoker" 
     address="http://localhost:8080/simpleWithAddress">
     <jaxws:implementor>
        <bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
     </jaxws:implementor>
     <jaxws:invoker>
        <bean class="org.apache.cxf.jaxws.spring.NullInvoker"/>
     </jaxws:invoker>
  </jaxws:endpoint>

</beans>

If you are a Spring user, you'll notice that the jaxws:properties element follows the Spring Map syntax.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!