如何创建与Apache骆驼弹簧WS SOAP错误
问题描述:
下面的场景与Apache的骆驼2.14.0,弹簧WS 1.5.9和1.2.9公理如何创建与Apache骆驼弹簧WS SOAP错误
方案 工作 - 当我们的肥皂服务被调用时,应该可选返回一个错误 - 这个错误应该是在回应肥皂故障
问题检测
我已经发现了问题: - Spring-WS的org.springframework.ws.soap.axiom.AxiomHandler(2.3.0)不会创建SOAPFault对象 - org.apache.axiom.soap.impl.llom.SOAPBodyImpl(1.2.15)不再检查元素的本地名称
问题 它有没有更好的方式来处理与Apache骆驼的SOAP错误?
- 一种可能性是使用throwException但比我的日志将包含大量的堆栈跟踪的功能误差
的情况下摘录 下面是骆驼配置的片断
<camel:from uri="spring-ws:uri:/contextPath/soapServices?endpointMapping=#endpointMapping"/>
<camel:to uri="bean:someBean" />
<camel:choice>
<camel:when>
<camel:xpath>//error</camel:xpath>
<camel:to uri="xslt:transform_event_response_to_soapfault.xslt?saxon=true" />
</camel:when>
</camel:choice>
</camel:from>
答
我们使用的解决方案不是,如下所示: 将原始邮件存储在标题中并引发异常。 spring-ws组件会自动将其转换为肥皂故障。还要添加CamelFailuerHandled,以便错误消息不在日志文件中。
<camel:setHeader headerName="myErrorMessage">
<camel:xpath>//error/text()</camel:xpath>
</camel:setHeader>
<camel:setProperty propertyName="CamelFailureHandled">
<camel:constant>true</camel:constant>
</camel:setProperty>
<camel:throwException exceptionType="java.lang.IllegalArgumentException" message="${header.myErrorMessage}"/>