camel-users mailing list archives

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


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:from uri="direct:rest"/>
            <camel:to uri="restlet:"/>
            <camel:process ref="header.logger" />
            <camel:unmarshal ref="json" />

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

[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]
[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?

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message