concept camel - cxf in category camel

appears as: camel-cxf
Camel in Action

This is an excerpt from Manning's book Camel in Action.

When using camel-cxf, you need to configure the CXF REST server, which can be done in two ways:

Listing 10.5 Camel route using camel-cxf to define four REST services
public class OrderRoute extends RouteBuilder { public void configure() throws Exception { from("cxfrs:http://localhost:8080 ?resourceClasses=camelinaction.RestOrderService &bindingStyle=SimpleConsumer")     #1 .toD("direct:${header.operationName}");     #2 from("direct:createOrder")     #3 .bean("orderService", "createOrder"); from("direct:getOrder")     #4 .bean("orderService", "getOrder(${header.id})"); from("direct:updateOrder")     #5 .bean("orderService", "updateOrder"); from("direct:cancelOrder")     #6 .bean("orderService", "cancelOrder(${header.id})"); } } #1 Camel-configured endpoint of REST service using CXF-RS #2 Calls the route that should perform the selected REST operation #3 REST service to create order #4 REST service to get order by ID #5 REST service to update order #6 REST service to cancel order by ID

When using camel-cxf, the REST web service is defined in a single route ❶ where you configure the hostname and port the REST server uses. When using camel-cxf, it’s recommended to use the SimpleConsumer binding style, which binds to the natural JAX-RS types and Camel headers. The default binding style uses the org.apache.cxf.message.MessageContentsList type from CXF, which is a lower-level type like Camel’s Exchange. The last configured option is the resourceClasses option ❶, which refers to a class or interface that declares the REST web service by using the JAX-RS standard.