骆驼的CXF组件未捕获onException(Exception.class) [英] Camel's CXF component not catching onException(Exception.class)

查看:141
本文介绍了骆驼的CXF组件未捕获onException(Exception.class)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启动了camel-cxf Web服务。我曾经使用CXF的SOAP Fault Interceptor机制来处理所有SOAP Fault。

I have a camel-cxf webservice up. I use to handle all SOAP Faults in the CXF's SOAP Fault Interceptor mechanism. That is working well.

我认为最好在同一层处理Camel层抛出的Exception,并编写了一个简单的onException方案,如下所示:

I thought that its better to handle Exception thrown at the Camel layer at the same layer and wrote a simple onException scenario like this:

onException(Exception.class)。
to( direct:MyWSExceptionHandler);

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

无论何时抛出自定义异常,我都希望onException能够启动(记住,我也有一个SOAP故障拦截器),但事实并非如此。 CXF正在接管,并且消息正在通过拦截器,而不是通过骆驼路线。

Whenever a custom exception is thrown, I was expecting the onException to kick in(Remember I also have a SOAP Fault Interceptor too), but it doesn't. The CXF is taking over and the message is going through the Interceptors, rather than the Camel Route.

这是预期的方式吗,还是我做错了什么?

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

我的CXF故障拦截器如下:

My CXF fault interceptor 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 please tell how to fix this? I don't want Exception generated at the Camel layer to leave that layer without being handled..

预先感谢。

推荐答案

Camel的onException仅在出现异常时触发。 SOAP故障以故障标志= true表示为一条消息。

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

您可以做的是在CamelContext上设置handleFault = true,然后它将SOAP错误消息转换为onException可以响应的异常。

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.

这篇关于骆驼的CXF组件未捕获onException(Exception.class)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆