Hi

This is the CxfRsproducer code I see may be related:

// set response
if (exchange.getPattern().isOutCapable()) {
            LOG.trace("Response body = {}", response);

exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());

exchange.getOut().setBody(binding.bindResponseToCamelBody(response, exchange));

exchange.getOut().getHeaders().putAll(binding.bindResponseHeadersToCamelHeaders(response, exchange)); exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, statesCode);
        }


Does it help ?

Cheers, Sergey


On 30/04/14 21:57, jarlyons wrote:
I've been trying everything I can think of to successfully invoke a remote
REST service and capture the response purely within a spring camel file.

I've got a setup that appears to do everything I need, but for the life of
me I can't figure out how to capture the response.

On top of it all, by setting the loggingFeatureEnabled="true" in the
rsClient, I can see the service response printed to standard out, but the
archive file it writes to disk is empty.

Does anyone have any suggestions?

------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:cxf="http://camel.apache.org/schema/cxf";
    xsi:schemaLocation=" http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
                         http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
                         http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd";>


         <cxf:rsClient id="rsClient"
address="http://xxx.xxx.xxx:8080/foo/rest/bar/verify";
                 serviceClass="Foo.Bar.TestReply"
                 loggingFeatureEnabled="true" username=user" password="pwd">
         </cxf:rsClient>

         <camelContext id="integrationTesting"
xmlns="http://camel.apache.org/schema/spring";>

                 <dataFormats>
                         <json id="gson" library="Gson"
unmarshalTypeName="Foo.Bar.Test"/>
                         <json id="gsonResponse" library="Gson"
unmarshalTypeName="Foo.Bar.TestReply"/>
                 </dataFormats>

                 <route>
                         <from  uri="direct:httpAPI"/>
                         <inOut uri="cxfrs://bean://rsClient"/>
                         <bean   ref="debugExchange" method="process"/>

                 </route>

         <route>
            <from
uri="timer://gsonUsingHttpAPI?fixedRate=true&amp;period=120000&amp;repeatCount=1"/>
            <transform>
                <simple>{"param1" : 29,"param2" : 13,"param3" : "02","param4"
: "1234"}</simple>
            </transform>
            <setHeader headerName="CamelHttpMethod">
              <constant>PUT</constant>
            </setHeader>
            <setHeader headerName="Content-Type">
              <constant>application/json</constant>
            </setHeader>
            <to   uri="direct:httpAPI"/>
         </route>

         </camelContext>

         <bean id="debugExchange"
class="Tideworks.GateVision.camel.PrintBodyProcessor"/>

</beans>

---------------------------------------------------------------------------------------------------------------

Here is the output ......


invoke_junit:
      [echo] JVM arguments: -Dgms.server=172.16.66.44
     [junit] Running Tideworks.GateVision.KioskHandler.NoOpTest
    [junit] Apr 30, 2014 1:42:04 PM org.apache.cxf.jaxrs.utils.ResourceUtils
checkMethodDispatcher
     [junit] WARNING: No resource methods have been found for resource class
Tideworks.GateVision.VanguardTestReply
     [junit] Apr 30, 2014 1:42:06 PM
org.apache.cxf.interceptor.LoggingOutInterceptor
     [junit] INFO: Outbound Message
     [junit] ---------------------------
     [junit] ID: 1
     [junit] Address: http://xxx.xxx.xxx:8080/foo/rest/bar/verify
     [junit] Http-Method: PUT
     [junit] Content-Type: application/json
     [junit] Headers: {firedTime=[Wed Apr 30 13:42:05 PDT 2014],
Content-Type=[application/json],
breadcrumbId=[ID-lyons-ubuntu-53546-1398890523707-0-1],
org.apache.cxf.request.method=[PUT], Authorization=[Basic
R01TVVNFUjpnbXN0ZXN0], Accept=[*/*]}
     [junit] Payload: {"param1" : 29,"param2" : 13,"param3" : "02","param4" :
"1234"}
     [junit] --------------------------------------
     [junit] EXCHANGE IN: message: Exchange[Message:
{"returnCode":1,"beforeData":null,"afterData":null,"messageStack":[],"tooManyRowsChoices":null,"returnMessage":null,"messageStackSize":0}]
     [junit] Apr 30, 2014 1:42:07 PM
org.apache.cxf.interceptor.LoggingInInterceptor
     [junit] INFO: Inbound Message
     [junit] ----------------------------
     [junit] ID: 1
     [junit] Response-Code: 200
     [junit] Encoding: ISO-8859-1
     [junit] Content-Type: application/json
     [junit] Headers: {content-type=[application/json], Date=[Wed, 30 Apr
2014 20:41:24 GMT], Server=[Apache-Coyote/1.1],
Set-Cookie=[JSESSIONID=97086BE1BE4A61D4819D5811492DC590; Path=/Regatta/;
HttpOnly], transfer-encoding=[chunked]}
     [junit] Payload:
{"returnCode":1,"beforeData":null,"afterData":null,"messageStack":[],"tooManyRowsChoices":null,"returnMessage":null,"messageStackSize":0}
     [junit] --------------------------------------
     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.688 sec
[junitreport] Processing /home/jar/---------
---/junit_results/TESTS-TestSuites.xml to /tmp/null15503331
[junitreport] Loading stylesheet
jar:file:/usr/share/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] Transform time: 1173ms
[junitreport] Deleting: /tmp/null15503331
      [echo] All tests complete ... review results in ./build/junit_results




--
View this message in context: 
http://camel.465427.n5.nabble.com/rsClient-successfully-invoking-REST-service-but-where-is-the-response-tp5750734.html
Sent from the Camel - Users mailing list archive at Nabble.com.



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to