You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

CXF Component

The cxf: component provides integration with Apache CXF for connecting to JAX-WS services hosted in CXF.

URI format

cxf://address?options

Where address represents the CXF endpoint's address

cxf:bean:cxfEndpoint

Where cxfEndpoint repesents the spring bean's name which presents the CXF endpoint

Options

Name

Description

Example

default value

wsdlURL

The location of the WSDL.

file://local/wsdl/hello.wsdl or wsdl/hello.wsdl

 

serviceClass

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

org.apache.camel.Hello

 

serviceName

The service name this service is implementing, it maps to the wsdl:service@name.

{

http://org.apache.camel

}
ServiceName

 

portName

The port name this service is implementing, it maps to the wsdl:port@name.

{

http://org.apache.camel

}
PortName

 

dataFormat

Which data type message that CXF endpoint support

POJO, PAYLOAD, MESSAGE

POJO

The descriptions of the dataformats

DataFormat

Description

POJO

POJOs (Plain old Java objects) are the Java parameters to the method, it is invoking on the target server.

PAYLOAD

PAYLOAD is the message payload of the message after message configured in the CXF endpoint is applied.

MESSAGE

MESSAGE is the raw message that is received from the transport layer.

Configure the CXF endpoints with spring

You can configure the CXF endpoint with the below spring configuration file , and you can also embedded the endpoint into the camelContext tags.

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"
          
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/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 jaxws:endpoint 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 jaxws 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>s or <ref>s.

cxf:inFaultInterceptors

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

cxf:outInterceptors

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

cxf:outFaultInterceptors

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

cxf:properties

A properties map 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

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

  • No labels