Exposure of Camel routes as REST services under Web container

oiavorskyi picture oiavorskyi · Apr 14, 2011 · Viewed 9.7k times · Source

I have Camel route that I would like to expose as a REST Web Service. Application is deployed on Web container (Jetty/Tomcat) and Spring is used as well for DI and other "infrastructural" things.

I took a look at both camel-restlet and camel-cxfrs components and while they both provide support for exposing routes as REST services I was not able to find out how to avoid starting of separate server. What I'm really looking for is ability to define Camel route in a similar way to how routes are defined for Spring-WS inbound endpoints, e.g.

from("restlet://application/user/{id}").to(...)

Configuration of Web application should take care of accepting requests and transferring them to appropriate endpoints.

Have to admit I was pretty much surprised that I was not able to find sufficient info on the topic and I don't think that my requirements are very exotic.

Answer

Claus Ibsen picture Claus Ibsen · Apr 14, 2011

See this example http://camel.apache.org/cxf-tomcat-example.html

For Apache CXF you can use the servlet transport which allows you to tap into Tomcat/Jetty being the host container.

And if you use OSGi then take a look at this: http://camel.apache.org/cxf-example-osgi.html it shows how to use CXF with OSGi HTTP service, that should work as well for CXFRS.