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

Compare with Current View Page History

« Previous Version 2 Next »

CXFRS Component

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

Maven users will need to add the following dependency to their pom.xml for this component:

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

URI format

cxfrs://address?options

Where address represents the CXF endpoint's address

cxfrs:bean:rsEndpoint

Where rsEndpoint represents the spring bean's name which presents the CXFRS client or server

For either style above, you can append options to the URI as follows:

cxf:bean:cxfEndpoint?ResourceClass=org.apache.camel.rs.Example

Options

Name

Description

Example

Required?

default value

ResourcesClass

The resource classes which you want to export as REST service

resourcesClass=org.apache.camel.rs.Example1,org.apache.camel.rs.Exchange2

Yes

None

You can also configure the CXF REST endpoint through the spring configuration. Since there are lots of difference between the CXF REST client and CXF REST Server, we provides different configuration for them.
Please check out the schema file and CXF REST user guide for more information.

How to consumer the REST request in Camel ?

CXF JAXRS front end implements the JAXRS(JSR311) API, so we can export the resources classes as a REST service. And we leverage the CXF Invoker API to turn a REST request into a normal Java object method invocation.
Unlike the camel-restlet, you don't need to specify the URI template within your restlet endpoint, CXF take care of the REST request URI to resource class method mapping according to the JSR311 specification. All you need to do in Camel is delegate this method request to a right processor or endpoint.

Here is an example

Error formatting macro: snippet: java.lang.NullPointerException

How to invoke the REST service through camel-cxfrs producer ?

CXF JAXRS front end implements a proxy based Client API, with this API you can invoke the remote REST service through a proxy.
camel-cxfrs producer is based on this proxy API.
So, you just need to specify the operation name in the message header and prepare the parameter in the message body, camel-cxfrs producer will generate right REST request for you.

Here is an example

Error formatting macro: snippet: java.lang.NullPointerException
  • No labels