camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bitter geek <bitterg...@gmail.com>
Subject How to handle http status code
Date Mon, 23 Jul 2012 15:43:18 GMT
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!

Bing

Mime
View raw message