The HTTP response code should be set by the restlet component http://camel.apache.org/restlet
So you can just test this code <choice> <when> <simple>${header.CamelHttpResponseCode} == 200</simple> <to uri="xxx"/> </when> <otherwise> ... not 200 so something is wrong </otherwise> On Thu, Sep 30, 2010 at 10:52 PM, mat127 <p3tr.matou...@gmail.com> wrote: > > Hi Ashwin, > > thank you for your answer. > > You are right there is no exception handling in the code I posted. That is > because the exception that is raised during the route execution is related > to the parsing of the http response: > > SEVERE: Failed delivery for exchangeId: > 26a0911d-9ffc-4366-9c46-cef2084e6a24. Exhausted after delivery attempt: 1 > caught: org.codehaus.jackson.JsonParseException: Unexpected character ('<' > (code 60)): expected a valid value (number, String, array, object, 'true', > 'false' or 'null') > at [Source: java.io.bytearrayinputstr...@1f0d7f5; line: 1, column: 2] > org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code > 60)): expected a valid value (number, String, array, object, 'true', 'false' > or 'null') > at [Source: java.io.bytearrayinputstr...@1f0d7f5; line: 1, column: 2] > at > org.codehaus.jackson.impl.JsonParserBase._constructError(JsonParserBase.java:651) > at > org.codehaus.jackson.impl.JsonParserBase._reportError(JsonParserBase.java:635) > at > org.codehaus.jackson.impl.JsonParserBase._reportUnexpectedChar(JsonParserBase.java:576) > at > org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:194) > at > org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:1039) > at > org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:995) > at > org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:818) > at > org.apache.camel.component.jackson.JacksonDataFormat.unmarshal(JacksonDataFormat.java:70) > ... > > But this parsing is useless in case that HTTP status is not 200 as the body > of the message does not contain expected JSON data but html error message > instead. Handling this kind of exception would mean that the data is > corrupted but received fine which is not true. That is why I want to find > some access to http status that restlet component has received from the > server and avoid any parsing (by filtering e.g.) in case it is not 200 OK. > > Imagine the route without the unmarshalling: > > <camel:route> > <camel:from uri="direct:rest"/> > <camel:to uri="restlet:http://somewhere.net/path/to/rest/api"/> > <camel:process ref="header.logger" /> > </camel:route> > > In this case there will be no exception even the REST API would respond with > some HTTP status != 200. > > Anyway the exchange.getOut.isFailed() is false too as you can see from the > log: > > [DEBUG] [2010-09-30 14:57:47,018] [main] > c.b.i.c.a.l.ExchangeHeadersInspector: exchange.failed: false > > Petr > -- > View this message in context: > http://camel.465427.n5.nabble.com/Restlet-HTTP-status-and-message-tp3047023p3047644.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