Hello guys! I need a help, again…This time about REST and CXF. I've moved from restlet component to CXF and it raised quite a lot of questions, it was easier with Restlet, but now I have to deal with CXF.
At least, I have a working "proof of concept" of the REST API with CXF in Camel, that works, but, it's not looking "nice and clean" for me, so I have few questions, if all this is really ok and that is the "recommended" or something like this :) First, I have declared a "face" of the REST API: public class DemoServer { @GET @Path("/hellodemo/{hello}") @Produces("text/plain") public Response demoHello(@PathParam("hello") String hello) { return null; } @GET @Path("/{foo}/bar") @Produces("text/plain") public Response fooHello(@PathParam("foo") String foo) { return null; } } Then, I've registered this "DemoServer" as "cxf:rsServer" in blueprint.xml: <camel-cxf:rsServer id="demoServer" address="${server.cxfrest.base}/demo/" serviceClass="com.my.example.DemoServer"/> And then, finally, the Camel route: from("cxfrs:bean:demoServer") .choice() .when(header(CxfConstants.OPERATION_NAME).isEqualTo("demoHello")) .to("bean:demoBean") .when(header(CxfConstants.OPERATION_NAME).isEqualTo("fooHello")) .to("bean:fooBean") .otherwise() .to("bean:anotherBean"); Now, questions :) First of all, is that really correct? It should be like that? Well, I'm fine with that, but few things looks weird to me. My intention is to have REST API on the consumer endpoint side, in the middle is some processing, based on inputs from the REST requests, and on the produce endpoint side, there is almost all the time HTTP reponse with some content back to browser (JSON data, usually). So, for example, the implementation of "DemoServer" looks weird, I don't like the "return null" there. Yes it works like it should, like I need, but this looks odd. Then, in the route definition, there is the content based router, this choice()/when() things, because I need to differentiate each actions from "DemoServer" - correct? What I'd like to see, is ability to define a separate route for each method in the "DemoServer". Again, it works, but I'm not sure about pros/cons too much here :) With Restlet, I've had there separate route for each kind of REST requests, it was easy to have like that. So, maybe it's just wrong, maybe not, that's why I'm asking :) Thank you guys, for any hint. -- S pozdravem Martin Stiborský Jabber: st...@njs.netlab.cz