Camel CXF component not infecting onException (Exception.class)

I have a camel-cxf web service. I use to handle all SOAP errors in the CXF SOAP Fault Interceptor. It works well.

I thought it was better to handle the Exception thrown on the Camel layer on the same layer, and wrote a simple onException script like this:

OnException (Exception.class). to ("direct: MyWSExceptionHandler");

Whenever a custom exception is thrown, I expected onException to hit (remember that I also have a SOAP error trap), but that is not the case. CXF takes over, and the message goes through interceptors, not the camel route.

Is this the expected way, or am I doing something wrong?

My CXF error trap looks like this:

@Component("SOAPFaultInterceptor") public class SOAPFaultInterceptor extends AbstractPhaseInterceptor { public SOAPFaultInterceptor() { super(Phase.MARSHAL); } public void handleMessage(Message message) throws Fault { // The message is coming here directly, instead of going to the route defined by onException. } } 

Can someone tell me how to fix this? I do not want the Exception thrown on the Camel layer to leave this layer unhandled.

Thanks in advance.

+4
source share
1 answer

Camel onException fires only when there is an exception. SOAP Fault appears as a message with the error flag = true.

What you can do is set handleFault = true to CamelContext, then it will turn SOAP error messages into an exception that onException can respond to.

+3
source

Source: https://habr.com/ru/post/1480098/


All Articles