Hi I have created a ticket https://issues.apache.org/activemq/browse/CAMEL-3184
To add an option to the restlet component so it works more like the http component. The http component will throw an exception if the code != 200. I think we should do the same for the restlet. This makes it easier to handle errors. On Thu, Sep 30, 2010 at 3:44 PM, mat127 <p3tr.matou...@gmail.com> wrote: > > 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. > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus