Configure the CXF endpoints with Spring - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

You can configure the CXF endpoint with the Spring configuration file shown below, and you can also embed the endpoint into the camelContext tags. When you are invoking the service endpoint, you can set the operationName and operationNamespace headers to explicitly state which operation you are calling.

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

   <cxf:cxfEndpoint id="routerEndpoint" 
      address="http://localhost:9003/CamelContext/RouterPort"
      serviceClass="org.apache.hello_world_soap_http.GreeterImpl"/>
            
   <cxf:cxfEndpoint id="serviceEndpoint" 
      address="http://localhost:9000/SoapContext/SoapPort"
      wsdlURL="testutils/hello_world.wsdl"
      serviceClass="org.apache.hello_world_soap_http.Greeter"
      endpointName="s:SoapPort"
      serviceName="s:SOAPService"
      xmlns:s="http://apache.org/hello_world_soap_http" />
                  
   <camelContext id="camel" 
      xmlns="http://activemq.apache.org/camel/schema/spring">
      <route>
         <from uri="cxf:bean:routerEndpoint" />
         <to uri="cxf:bean:serviceEndpoint" />
      </route>
   </camelContext>
</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 <cxf:cxfEndpoint/> tag--these are required because the combined { namespace}localName syntax is presently not supported for this tag's attribute values.

The cxf:cxfEndpoint element supports many additional attributes:

Name

Value

PortName

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

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.

wsdlURL

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

bindingId

The bindingId for the service model to use.

address

The service publish address.

bus

The bus name that will be used in the JAX-WS endpoint.

serviceClass

The class name of the SEI (Service Endpoint Interface) class which could have JSR181 annotation or not.

It also supports many child elements:

Name

Value

cxf:inInterceptors

The incoming interceptors for this endpoint. A list of <bean> or <ref>.

cxf:inFaultInterceptors

The incoming fault interceptors for this endpoint. A list of <bean> or <ref> .

cxf:outInterceptors

The outgoing interceptors for this endpoint. A list of <bean> or <ref> .

cxf:outFaultInterceptors

The outgoing fault interceptors for this endpoint. A list of <bean> or <ref> .

cxf:properties

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

cxf:handlers

A JAX-WS handler list which should be supplied to the JAX-WS endpoint. See below.

cxf:dataBinding

You can specify the which DataBinding will be use in the endpoint. This can be supplied using the Spring <bean class="MyDataBinding"/> syntax.

cxf:binding

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

cxf:features

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

cxf:schemaLocations

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

cxf:serviceFactory

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

You can find more advanced examples that show how to provide interceptors, properties and handlers on the CXF JAX-WS Configuration page.

NOTE You can use cxf:properties to set the camel-cxf endpoint's dataFormat and setDefaultBus properties from Spring configuration file.

<cxf:cxfEndpoint id="testEndpoint" address="http://localhost:9000/router"
   serviceClass="org.apache.camel.component.cxf.HelloService"
   endpointName="s:PortName"
   serviceName="s:ServiceName"
   xmlns:s="http://www.example.com/test">
   <cxf:properties>
      <entry key="dataFormat" value="MESSAGE"/>
      <entry key="setDefaultBus" value="true"/>
   </cxf:properties>
</cxf:cxfEndpoint>