CXF Bean Component (2.0 or later)
The cxfbean: component allows other Camel endpoints to send exchange and invoke Web service bean objects. (Currently, it only supports JAXRS, JAXWS(new to camel2.1) annotated service bean.)
Note: CxfBeanEndpoint
is a ProcessorEndpoint
so it has no consumers. It works similarly to a Bean component.
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
Name |
Description |
Example |
Required? |
Default Value |
---|---|---|---|---|
|
CXF bean binding specified by the |
|
No |
|
|
CXF bus reference specified by the |
|
No |
Default bus created by CXF Bus Factory |
|
Header filter strategy specified by the |
|
No |
|
|
Will set the default bus when CXF endpoint create a bus by itself. |
|
No |
|
|
Since 2.3, the wsdlLocation annotated in the POJO is ignored (by default) unless this option is set to |
|
No |
|
|
Since 2.5, setting the providers for the CXFRS endpoint. |
|
No |
|
Headers
Name |
Description |
Type |
Required? |
Default Value |
In/Out |
Examples |
---|---|---|---|---|---|---|
|
Character encoding |
|
No |
None |
In |
ISO-8859-1 |
|
Content type |
|
No |
*/* |
In |
|
CamelHttpBaseUri |
The value of this header will be set in the CXF message as the |
|
Yes |
The Endpoint URI of the source endpoint in the Camel exchange |
In |
|
|
Request URI's path |
|
Yes |
None |
In |
|
|
RESTful request verb |
|
Yes |
None |
In |
|
|
HTTP response code |
|
No |
None |
Out |
200 |
Note: Currently, CXF Bean component has (only) been tested with Jetty HTTP component it can understand headers from Jetty HTTP component without requiring conversion.
A Working Sample
This sample shows how to create a route that starts a Jetty HTTP server. The route sends requests to a CXF Bean and invokes a JAXRS 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 RESTful request URI will not match the endpoint's URI http://localhost:9000 exactly.
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.
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.