【发布时间】:2014-08-09 07:57:39
【问题描述】:
我想做什么:
在 CXF 端点中使用架构验证实现从 CXF Endpoint 到 JMS queue 的 Camel route。
在 CXF 端点中启用了验证:
/* Set endpoint properties */
Map<String, Object> propertiesMap = new HashMap<String, Object>();
propertiesMap.put("schema-validation-enabled", "true");
/* Create endpoint */
CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setWsdlURL("wsdl/input.wsdl");
cxfEndpoint.setDataFormat(DataFormat.CXF_MESSAGE);
cxfEndpoint.setProperties(propertiesMap);
cxfEndpoint.getInInterceptors().add(new FaultInterceptor());
骆驼路线:
from(cxfEndpoint)
.routeId("INPUT_ROUTE")
.to("jms:foo.bar");
CXF 拦截器:
public class FaultInterceptor extends AbstractSoapInterceptor {
private static final Logger LOGGER = Logger.getLogger(FaultInterceptor.class);
public FaultInterceptor() {
super(Phase.UNMARSHAL);
}
public void handleMessage(SoapMessage message) throws Fault {
LOGGER.info("handleMessage=" + message.getExchange().getInMessage());
}
@Override
public void handleFault(SoapMessage message) {
Fault fault = (Fault) message.getContent(Exception.class);
LOGGER.info("handleFault='" + fault + "'");
/* Add some header property that says the message is invalid */
}
}
问题:
如果我发送有效的 SOAP 消息,则工作正常。如果我发送无效的 SOAP 消息,handleFault 方法就会启动,记录错误,仅此而已。
对于无效的 SOAP 消息场景,我是否可以使用 handleFault 方法记录故障并仍然将无效消息路由到 JMS 队列?
这是我添加到端点的唯一拦截器。
我正在使用:
- Apache ServiceMix 5.0.0
- Apache Camel 2.12.3
- Apache CXF 2.7.10
【问题讨论】:
标签: web-services cxf apache-camel interceptor