Hi, I am trying to consume a REST webservice using the cxfrs component. The code looks as below:
<cxf:rsClient id="restClient" address="http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet" serviceClass="org.examples.camel.camel_cxfrs_client.HelloWorldIntf"> <cxf:features> <ref bean="cxfLoggingFeature" /> </cxf:features> <cxf:providers> <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"></bean> </cxf:providers> </cxf:rsClient> And the corresponding route is as follows. From my java program i am invoking this route which invokes the service and i am able to see the response. <route> <from uri="direct:start" /> <setHeader headerName="CamelHttpMethod"> <camel:constant>GET</camel:constant> </setHeader> <to uri="cxfrs:bean:restClient?synchronous=true" /> <convertBodyTo type="java.lang.String" /> <log message="response received from service is.....${body}" /> <process ref="responseProcessor" /> </route> In the console output i can see the following output: ---------------------------- ID: 1 Response-Code: 200 Encoding: ISO-8859-1 Content-Type: text/plain Headers: {content-type=[text/plain], Date=[Wed, 19 Aug 2015 12:18:31 GMT], Server=[Apache-Coyote/1.1], transfer-encoding=[chunked]} Payload: Hi There!!! -------------------------------------- [ main] Tracer INFO >>> (route1) cxfrs://bean:restClient?synchronous=true --> log[response received from service is.....${body}] <<< Pattern:InOnly, Headers:{CamelHttpMethod=GET, BodyType:null, Body:[Body is null] [ main] route1 INFO response received from service is..... [ main] Tracer INFO >>> (route1) log[response received from service is.....${body}] --> ref:responseProcessor <<< Pattern:InOnly, Headers:{CamelHttpMethod=GET, BodyType:null, Body:[Body is null] As you can see i am getting my response from the Web service in the Payload part. It is a simple GET request that returns a string - "Hi There!!!". I am trying to display the same using the ${body} in the log component, but what i am getting is null Body and the BodyType too is set to null. I tried the same using camel http component. The route looks as below: <route> <from uri="direct:start" /> <log message="invoking the rest service...." /> <setHeader headerName="CamelHttpMethod"> <camel:constant>GET</camel:constant> </setHeader> <to uri="http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet" /> <log message="response received from service is.....${body}" /> <process ref="responseProcessor" /> </route> Console Output looks as below. [ main] Tracer INFO >>> (route1) from(direct://start) --> log[invoking the rest service....] <<< Pattern:InOnly, Headers: BodyType:null, Body:[Body is null] [ main] route1 INFO invoking the rest service.... [ main] Tracer INFO >>> (route1) log[invoking the rest service....] --> setHeader[CamelHttpMethod] <<< Pattern:InOnly, Headers: BodyType:null, Body:[Body is null] [ main] Tracer INFO >>> (route1) setHeader[CamelHttpMethod] --> http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet <<< Pattern:InOnly, Headers:{CamelHttpMethod=GET}, BodyType:null, Body:[Body is null] [ main] Tracer INFO >>> (route1) http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet --> log[response received from service is.....${body}] <<< Pattern:InOnly, Headers:{Content-Type=text/plain, CamelHttpResponseCode=200, Server=Apache-Coyote/1.1, Transfer-Encoding=chunked, CamelHttpMethod=GET, Date=Wed, 19 Aug 2015 12:22:56 GMT}, BodyType:org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream, Body:[Body is instance of java.io.InputStream] [ main] route1 INFO response received from service is.....Hi There!!! Using http component, i am able to capture the response in the ${body} which i can use further down in the route. I looked into the documentatino for the cxfrs component to understand the behavior of the rs:Client module but it is of less use. Can some body please provide some explaination on the below points. 1) Why is it that for cxfrs component the payload was not set in the message body? 2) Any advantages/disadvantages of choosing cxfrs over http and vice-versa? 3) When using the cxfrs component, there is an option to set httpClientAPI to either true/false. When this value is set to true, CxfRsProducer will use HttpClientAPI to invoke the service. What does this mean? Are there other APIs available to invoke the service? Camel core and components Version - 2.13.2 CXF Version - 2.7.11 Thanks, Kalyan -- View this message in context: http://camel.465427.n5.nabble.com/camel-http-v-s-cxfrs-component-to-consume-REST-service-tp5770829.html Sent from the Camel - Users mailing list archive at Nabble.com.