You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kafe <er...@gmail.com> on 2012/01/12 18:01:40 UTC

CXF - REST service response

Hi !

I'm currently trying to deal with REST web services together with Camel and
CXF.
I have the following route (simplified here) :

<route id="callRestService">
   <from uri="jms:queue:incomingXmlOrder" />
   <bean ref="restHeaderProcessor"  method="process"/>
   <to uri="cxfrs://http://localhost:8082/services"/>
   <to uri="log:output" />
</route>

My restHeaderProcessor is doing something like this :

public MessageContentsList process(final Exchange exchange) throws Exception
{

   Message inMessage = exchange.getIn();
   inMessage.setHeader(Exchange.HTTP_METHOD, "POST");
   inMessage.setHeader(Exchange.HTTP_URI, "aaa/bbb/ccc"); // not real values
   inMessage.setHeader(Exchange.HTTP_PATH, "aaa/bbb/ccc"); // not real
values
   inMessage.setHeader(CxfConstants.OPERATION_NAME, "distantMethodToCall");
// not real value

   MessageContentsList contentsList = new MessageContentsList();
   contentsList.add("myStringParam");
   return contentsList;
}


I succeed in calling the distant REST service with my param but how can i
manage the service response.
After the call, i still have the MessageContentsList in my
Exchange.getIn().getBody().

Where is the REST service response available ??

Thank for your help?.

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-REST-service-response-tp5140445p5140445.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF - REST service response

Posted by Christian Müller <ch...@gmail.com>.
For an upcoming series of two articles in a German magazin, I wrote a
sample application which use the CXFRS component to call a JAX-RS service.
For the unit tests, I start a JAX-RS server to export a resource. It's
available at [1] and may also useful for you.

[1] https://github.com/muellerc/camel-in-daily-use

Best,
Christian

On Mon, May 21, 2012 at 3:31 PM, kafe <er...@gmail.com> wrote:

> My pleasure !
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/CXF-REST-service-response-tp5140445p5712907.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: CXF - REST service response

Posted by kafe <er...@gmail.com>.
My pleasure !

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-REST-service-response-tp5140445p5712907.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF - REST service response

Posted by wael <wa...@gmail.com>.
Dear Kafe

I would like to thank you very much for your post, it helped me alot to
create a restfull client from camel.

I was trying with cxfrs:rsclient with no luck and alot of problems with the
dependency between apache cxf and camel cxf.

But your post was straight forward.

Thank you.

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-REST-service-response-tp5140445p5712878.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF - REST service response

Posted by kafe <er...@gmail.com>.
I found the answer. Actually, my route was with pattern="InOnly".
I moved to "InOut" and that's ok now !

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-REST-service-response-tp5140445p5140657.html
Sent from the Camel - Users mailing list archive at Nabble.com.