Below is the example where you can find a Rest call with Apache Camel.
package camelinaction;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.apache.camel.spring.boot.FatJarRouter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class OrderRoute extends FatJarRouter {
@Bean(name = "jsonProvider")
public JacksonJsonProvider jsonProvider() {
return new JacksonJsonProvider();
}
@Override
public void configure() throws Exception {
// use CXF-RS to setup the REST web service using the resource class
// and use the simple binding style which is recommended to use
from("cxfrs:http://localhost:8080?resourceClasses=camelinaction.RestOrderService&bindingStyle=SimpleConsumer&providers=#jsonProvider")
// call the route based on the operation invoked on the REST web service
.toD("direct:${header.operationName}");
// routes that implement the REST services
from("direct:createOrder")
.bean("orderService", "createOrder");
from("direct:getOrder")
.bean("orderService", "getOrder(${header.id})");
from("direct:updateOrder")
.bean("orderService", "updateOrder");
from("direct:cancelOrder")
.bean("orderService", "cancelOrder(${header.id})");
}
}
Source code link :
https://github.com/camelinaction/camelinaction2/tree/master/chapter10/camel-cxf-rest-spring-boot.
I highly encourage to refer camelinaction2 as it covers many advance topics and it is written by @Claus Ibsen.