Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Name

Description

Example

Required?

default value

wsdlURL

The location of the WSDL.

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

No

WSDL is obtained from endpoint address by default

serviceClass

The name of the SEI(Service Endpoint Interface) class. This class can have but does not require JSR181 annotations. 

org.apache.camel.Hello

Yes

 

serviceName

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

{

http://org.apache.camelImage Removed

}
ServiceName

Only if more than one serviceName in WSDL present

 

Since 2.0, it is possible to use # notation to reference a serviceClass object instance from the registry.  E.g. serviceClass=#beanName Please be advised that the referenced object cannot be a Proxy (Spring AOP Proxy is OK).  Basically, it is relied on Object.getClass().getName() method for non Spring AOP Proxy.

org.apache.camel.Hello

Yes

 

serviceName

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

{http://org.apache.camel}
ServiceName

Only if more than one serviceName in WSDL present

 

portName

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

{

http://org.apache.camelImage Removed

}
PortName

Only if more than one portName under the serviceName is present

 

dataFormat

Which data type messages the CXF endpoint supports

POJO, PAYLOAD, MESSAGE

No

POJO

wrapped

Which kind of operation that CXF endpoint producer will invoke

true, false

No

false

implementing, it maps to the wsdl:port@name.

{http://org.apache.camel}
PortName

Only if more than one portName under the serviceName is present

 

dataFormat

Which data type messages the CXF endpoint supports

POJO, PAYLOAD, MESSAGE

No

POJO

wrapped

Which kind of operation that CXF endpoint producer will invoke

true, false

No

false

setDefaultBus

Will set the default bus when CXF endpoint create a bus by itself

true, false

No

false

bus

Since 2.0, use # notation to reference a bus object from the registry.  The referenced object must be an instance of org.apache.cxf.Bus.

bus=#busName

No

Default bus created by CXF Bus Factory

cxfBinding

Since 2.0, use # notation to reference a CXF binding object from the registry.  The referenced object must be an instance of org.apache.camel.component.cxf.CxfBinding.

cxfBinding=#bindingName

No

org.apache.camel.component.cxf.DefaultCxfBinding

headerFilterStrategy

Since 2.0, use # notation to reference a header filter strategy object from the registry.  The referenced object must be an instance of org.apache.camel.spi.HeaderFilterStrategy.

headerFilterStrategy=#strategyName

No

org.apache.camel.component.cxf.CxfHeaderFilterStrategy

setDefaultBus

Will set the default bus when CXF endpoint create a bus by itself

true, false

No

false

The serviceName and portName are QNames, so if you provide them be sure to prefix them with their {namespace} as shown in the examples above.

...

Code Block
java
java
<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://camel.apache.org/schema/cxfEndpoint http://camel.apache.org/schema/cxf/cxfEndpoint.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.

...

You can find more advanced examples which show how to provide interceptors , properties and handlers here:
http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.htmlImage Removed

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

Code Block
xml
xml


<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>

How to let camel-cxf component to use log4j instead of java.util.logging

...

The camel-cxf endpoint producer is based on the cxf client API. First you need to specify the operation name in the message header , then add the method parameters into a list and set the message with this parameter list will be ok. The response message's body is a messageContentsList, you can get the result from that list.

Wiki Markup
*NOTE* After Camel 1.5 , we change the message body from object array to message content list. If you still want to get the object array from the message body, you can get the body with this code message.getbody(Object\[\].class)

Wiki Markup
{snippet:id=sending|lang=java|url=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java}

...

PAYLOAD means you will get or set the payload message which has been take out the SOAP envelope from or into the CXF message. You can use the Header.HEADER_LIST as the key to set or get the SOAP headers and use the List<Element> to set or get SOAP body elements..HEADER_LIST as the key to set or get the SOAP headers and use the List<Element> to set or get SOAP body elements.

Change in 2.0, CxfMessage.getBody() will return a org.apache.camel.component.cxf.CxfPayload object, which has getters for SOAP message headers and Body elements.  This change enables decoupling the native CXF message from the Camel message. 

Wiki Markup
{snippet:id=payload|lang=java|url=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java}

...

cxf client API provides a way to invoke the operation with request and response context. If you are using camel-cxf endpoint producer to invoke the outside web service, you can set the request context and get response context with below codes.

Code Block
java
java

        CxfExchange exchange = (CxfExchange)template.send(getJaxwsEndpointUri(), new Processor() {
            public void process(final Exchange exchange) {
                final List<String> params = new ArrayList<String>();
                params.add(TEST_MESSAGE);
                // Set the request context to the inMessage
                Map<String, Object> requestContext = new HashMap<String, Object>();
                requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, JAXWS_SERVER_ADDRESS);
                exchange.getIn().setBody(params);
                exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext);
                exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, GREET_ME_OPERATION);
            }
        });
        org.apache.camel.Message out = exchange.getOut();
        // The output is an object array, the first element of the array is the return value        
        Object[] output = out.getBody(Object[].class);
        LOG.info("Received output text: " + output[0]);
        // Get the response context form outMessage
        Map<String, Object> responseContext = CastUtils.cast((Map)out.getHeader(Client.RESPONSE_CONTEXT));
        assertNotNull(responseContext);
        assertEquals("Get the wrong wsdl opertion name", "{http://apache.org/hello_world_soap_http}greetMe", responseContext.get("javax.xml.ws.wsdl.operation").toString());

Include Page
CAMEL:Endpoint See Also
CAMEL:Endpoint See Also