0

I'm building a route that sends a SOAP request to a webservice. For achieving that, I wrote this code.

.doTry()
    .inOut(getEndpointDocumentWS())
    .log("Response WHEN OKAY: ${body}")
    .process(Document_WS_REPLY_PROCESSOR)
.endDoTry()
.doCatch(Exception.class)
    .log(LoggingLevel.INFO, "SOAP REPLY WITH FAULTMESSAGE")
    .log("Response ON ERROR FAULT: ${body}")
    .process(Document_WS_REPLY_ERROR_PROCESSOR)
.end();

Everything goes as planned when the service response is "okay". Otherwise, when the service response is a soap:Fault, I'm not having access to all of the response (I am using soapUI to mock the soap:Fault response).

I can access a tiny fraction of the soap:fault by getting the EXCEPTION_CAUGHT property. The instruction

.log("Response ON ERROR FAULT: ${body}")

Has no data at all.

What can I do differently to have access to all the instead of only the faultstring?

Exception exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

noitib
  • 148
  • 1
  • 13

1 Answers1

0

According to this answer, Camel's CXF component not catching onException(Exception.class):

Camel's onException only triggeres if there is an exception. A SOAP Fault is represented as a Message with the fault flag = true.

What you can do is to set handleFault=true on CamelContext, then it will turn SOAP fault messages into an exception that the onException can react upon.

Assuming you have not configured handleFault=true, then it's odd that your exception handler is running at all. It could be that some other exception, not the Fault you're looking for, is occurring which causes the exception handler to run.

If you have already configured handleFault=true, I don't have any advice except inspect the data objects in a debugger to see if you can find out what's going on. (If you don't know, to do this you can add a Processor to your exception handler and insert a break point inside the Processor. Break points don't work in route definition because route definitions are only run on initialization.)

DavidS
  • 5,022
  • 2
  • 28
  • 55