camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <>
Subject Re: RESTful route with Apache CXF
Date Wed, 03 Oct 2012 11:23:35 GMT
Actually, here is the slightly updated code from one of the tests which 
Willem did:

protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
                 final ResponseBuilder builder = Response.ok();

                     // should be able to convert to Customer
                     // respond with OK

Note the cxfrs server endpoint accepts the request, the response object 
is run through the route and finally it can be set on the builder to do 
the marshalling done and the response returned.

The only thing I could not figure out quickly enough was how to actually 
get hold of this response object :-)

Cheers, Sergey

On 01/10/12 11:38, Sergey Beryozkin wrote:
> Hi Ralf
> On 01/10/12 07:50, Ralf Steppacher wrote:
>> Willam,
>> thanks for the hint. I shall look into camel-cxfrs.
>> Could you give me a usage example of the cxfbean component? What would
>> be a scenario where immediate marshalling to the client-requested format
>> is desired? Is the idea that all work necessary to produce a meaningful
>> response is done in the resource class and the route only consists of
>> the cxfbean endpoint?
> When you have a JAX-RS annotated bean with @Produces, it is not really
> possible to 'delay' marshalling of the response object.
> I think something interesting in this regard can also done with the new
> JAX-RS 2.0 AsyncResponse: say at the top of the route the JAX-RS request
> is accepted, suspended and resumed at some later stage (the end of the
> route). This just a theory at the moment though, not sure how it will
> can be coordinated with the Camel thread running the whole route
> Perhaps one working option is to register a custom JAX-RS
> MessageBodyReader which will simply cache the response object in its
> writeTo method and then at the end of the route this provider will be
> asked to 'flush' the response. Will it work for you ?
> Sergey
>> Thanks!
>> Ralf
>> -----Original Message-----
>> From: Willem jiang<>
>> Reply-to:
>> To:
>> Subject: Re: RESTful route with Apache CXF
>> Date: Thu, 27 Sep 2012 15:56:17 +0800
>> Hi Ralf,
>> I think you use misused the cxfbean component.
>> cxfbean component is trying to leverage the camel components to
>> provides different transports.
>> It will marshal and unmarshal the request and response out of box.
>> What's you need is camel-cxfrs[1] component, you should be able to get
>> the Java object of PriceReuqestMessage from the message body.
>> [1]

View raw message