attilav wrote:
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 just checked the HttpProducer code, the Response body is turn into
String instead of using the inputstream directly.
I will update the wiki page for it.
I need to access the response body, but the exchange.getException() returns
null.
You can get the exception by using below code in your processor.
Exception c = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class);
Willem
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