Hi
On 23/07/12 16:43, bitter geek wrote:
Hi All,

I have a router builder for a rest service with configure override
like the following:
...
@Override
        public void configure() throws Exception {
                from("direct:GetCustomer")
                .setHeader("Content-Type", 
constant("application/x-www-form-urlencoded"))
                .setHeader(Exchange.HTTP_METHOD, constant("GET"))
                .setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, 
constant(Boolean.TRUE))
                .setHeader(Exchange.HTTP_PATH, simple("${header.httpPath}"))
                .setHeader(Exchange.HTTP_QUERY,
                                simple(getURIComponentQuery()))
                .to(endpoint);
        }
...


The rest service returns an xml document. I don't have the xsd for it
so would like to set the type of the response to String via
convertBodyTo(String.class).

But once I do this, producerTemplate.requestBodyAndHeaders(null,
headers) returns a String object. So I lose the status code.

Noting converting it to string will let me access the status code but
then I no longer have the text body available.

Any idea how to get both the status code and the text body properly?

Thanks a lot for the help!
I can see from the code that a status code is set as Exchange.HTTP_RESPONSE_CODE header on the out message, so you should be able to get it from there

Cheers, Sergey


Bing

Reply via email to