Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.

CXF Bean Component

The cxfbean: component allows other Camel endpoints to send exchange and invoke Web service bean objects. Currently, it only supports JAX-RS and JAX-WS (new to Camel 2.1) annotated service beans.

CxfBeanEndpoint is a ProcessorEndpoint so it has no consumers. It works similarly to a Bean component.

Maven users need to add the following dependency to their pom.xml to use the CXF Bean Component:

xml<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cxf</artifactId> <!-- use the same version as your Camel core version: --> <version>x.x.x</version> </dependency>

URI format

cxfbean:serviceBeanRef

Where serviceBeanRef is a registry key to look up the service bean object. If serviceBeanRef references a List object, elements of the List are the service bean objects accepted by the endpoint.

Options

confluenceTableSmall

Name

Description

Example

Required?

Default Value

bus

CXF bus reference specified by the # notation. The referenced object must be an instance of org.apache.cxf.Bus.

bus=#busName

No

Default bus created by CXF Bus Factory

cxfBeanBinding

CXF bean binding specified by the # notation. The referenced object must be an instance of org.apache.camel.component.cxf.cxfbean.CxfBeanBinding.

cxfBinding=#bindingName

No

DefaultCxfBeanBinding

headerFilterStrategy

Header filter strategy specified by the # notation. The referenced object must be an instance of org.apache.camel.spi.HeaderFilterStrategy.

headerFilterStrategy=#strategyName

No

CxfHeaderFilterStrategy

populateFromClass

Since 2.3, the wsdlLocation annotated in the POJO is ignored (by default) unless this option is set to  false. Prior to 2.3, the wsdlLocation annotated in the POJO is always honored and it is not possible to ignore.

true, false

No

true

providers

Since 2.5, setting the providers for the CXFRS endpoint.

providers=#providerRef1,#providerRef2

No

null

setDefaultBus

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

true, false

No

false

Headers

confluenceTableSmall

Name

Description

Type

Required?

Default Value

In/Out

Examples

CamelHttpCharacterEncoding (before 2.0-m2: CamelCxfBeanCharacterEncoding)

Character encoding

String

No

None

In

ISO-8859-1

CamelContentType (before 2.0-m2: CamelCxfBeanContentType)

Content type

String

No

*/*

In

text/xml

CamelHttpBaseUri
(2.0-m3 and before: CamelCxfBeanRequestBasePath)

The value of this header will be set in the CXF message as the Message.BASE_PATH property. It is needed by CXF JAX-RS processing. Basically, it is the scheme, host and port portion of the request URI.

String

Yes

The Endpoint URI of the source endpoint in the Camel exchange

In

http://localhost:9000

CamelHttpPath (before 2.0-m2: CamelCxfBeanRequestPath)

Request URI's path

String

Yes

None

In

consumer/123

CamelHttpMethod (before 2.0-m2: CamelCxfBeanVerb)

RESTful request verb

String

Yes

None

In

GET, PUT, POST, DELETE

CamelHttpResponseCode

HTTP response code

Integer

No

None

Out

200

Currently, the CXF Bean component has (only) been tested with the Jetty component. It understands headers from Jetty component without requiring conversion.

A Working Sample

This sample shows how to create a route that starts an embedded Jetty HTTP server. The route sends requests to a CXF Bean and invokes a JAX-RS annotated service.

First, create a route as follows: The from endpoint is a Jetty HTTP endpoint that is listening on port 9000. Notice that the matchOnUriPrefix option must be set to true because the RESTful request URI will not exactly match the endpoint's URI http:­//localhost:9000.

{snippet:id=routeDefinition|lang=xml|url=camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanTest-context.xml}

The to endpoint is a CXF Bean with bean name customerServiceBean. The name will be looked up from the registry. Next, we make sure our service bean is available in Spring registry. We create a bean definition in the Spring configuration. In this example, we create a List of service beans (of one element). We could have created just a single bean without a List.

{snippet:id=beanDefinition|lang=xml|url=camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanTest-context.xml}

That's it. Once the route is started, the web service is ready for business. A HTTP client can make a request and receive response.

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram