Hi,

I'm trying to use camel-http to post a soap message. The remote server
returns  status code 500, with a body, which causes camel to throw a
HttpOperationFailedException.

According to the docs (http://camel.apache.org/http.html):
"""
This exception contains the following information:

    * The HTTP status code
    * The HTTP status line (text of the status code)
    * Redirect location, if server returned a redirect
    * Response body as a java.io.InputStream, if server provided a body as
response
"""

I need to access the response body, but the exchange.getException() returns
null.

Bellow us my setup, am I doing something wrong?

        from("direct:remotesender")
            .onException(HttpOperationFailedException.class) 
                .maximumRedeliveries(0)
                .process(new Processor() { 
                    public void process(Exchange exchange) throws Exception
{
                        log1.info("INBODY
----------------"+exchange.getIn().getBody(String.class));
                        log1.info("INHEAD
----------------"+exchange.getIn().getHeaders());
                        log1.info("OUTBODY
---------------"+exchange.getOut().getBody(String.class));
                        log1.info("OUTHEAD
---------------"+exchange.getOut().getHeaders());
                        log1.info("EXC
-------------------"+exchange.getException());
                        log1.info("FAIL
------------------"+exchange.isFailed());
                    }
                })              
                .end()             
            .setHeader(Exchange.HTTP_METHOD,
constant(org.apache.camel.component.http.HttpMethods.POST))
            .setHeader("SOAPAction",
constant("http://xxx.com/interfaces/ticket";))
            .to("http://iface.intra:8115/ticket";)


The output is:


org.apache.camel.component.http.HttpOperationFailedException: HTTP operation
failed invoking http://iface.nrps.telekom.intra:8115/fault_ticket with
statusCode: 500

2010-05-20 15:48:32,132 | INFO  | INBODY ----------------<REQUEST ...
2010-05-20 15:48:32,135 | INFO  | INHEAD ----------------{JMSType=null, ...
2010-05-20 15:48:32,138 | INFO  | OUTBODY ---------------null
2010-05-20 15:48:32,138 | INFO  | OUTHEAD ---------------{}
2010-05-20 15:48:32,138 | INFO  | EXC -------------------null
2010-05-20 15:48:32,138 | INFO  | FAIL ------------------false


Shouldn't the exchange.isFailed() be also be set?


thanks,
attilav
-- 
View this message in context: 
http://old.nabble.com/camel-http-how-to-retrieve-response-body-from-HttpOperationFailedException-tp28621982p28621982.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to