camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat127 <p3tr.matou...@gmail.com>
Subject Restlet HTTP status and message
Date Thu, 30 Sep 2010 13:44:20 GMT

Hi,

I am using the Restlet component for accessing a REST service and getting
some JSON data from it. What I need is to check the HTTP status of the
response but I do not know how. My route configuration is something like:

		<camel:route>
            <camel:from uri="direct:rest"/>
            <camel:to uri="restlet:http://somewhere.net/path/to/rest/api"/>
            <camel:process ref="header.logger" />
            <camel:unmarshal ref="json" />
		</camel:route>

The problem is that in case that REST returns something else than HTTP
status 200, the message body contains the error html message generated by
the web server and JSON unmarshaller than fails on it. I suppose the correct
way would be to check the HTTP status before the JSON unmarshalling and
react to HTTP status != 200. But how to get this value?

I tried to inspect the content of the Exchange generated by the restlet
component:

[DEBUG] [2010-09-30 14:57:47,017] [main]
c.b.i.c.a.l.ExchangeHeadersInspector: in.headers:
{org.restlet.http.headers=[Server: Apache-Coyote/1.1, Content-Type:
text/html;charset=utf-8, Content-Length: 1090, Date: Thu, 30 Sep 2010
12:57:46 GMT, Connection: close]}
[DEBUG] [2010-09-30 14:57:47,018] [main]
c.b.i.c.a.l.ExchangeHeadersInspector: exchange.properties:
{CamelToEndpoint=http://test.morosystems.cz:8086/ibillboardd/gwt/ds/kernel.adSpaceConfig/fetch}
[DEBUG] [2010-09-30 14:57:47,018] [main]
c.b.i.c.a.l.ExchangeHeadersInspector: exchange.failed: false

So the in.header[org.restlet.http.headers] header contains all the http
headers but the status is not here nor at any other place I tried
(Exchange.getProperties(), Exchange.isFailed()). Some hints anyone?

Petr
-- 
View this message in context: http://camel.465427.n5.nabble.com/Restlet-HTTP-status-and-message-tp3047023p3047023.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message