繁体   English   中英

如何使用Apache Camel Spring-WS创建肥皂故障

[英]How to create a soap fault with apache camel spring-ws

以下场景适用于Apache骆驼2.14.0,spring-ws 1.5.9和公理1.2.9

场景 -调用我们的soap服务时,它应该可选地返回一个错误-此错误应作为soap错误在响应中

问题检测

我已经检测到问题:-Spring-WS的org.springframework.ws.soap.axiom.AxiomHandler(2.3.0)不会创建SOAPFault对象-org.apache.axiom.soap.impl.llom.SOAPBodyImpl(1.2 .15)不再检查元素的本地名称

问题是否有更好的方法来处理apache骆驼的肥皂毛病?

  • 一种可能性是使用throwException,但是如果发生功能错误,我的日志将包含很多stacktrace

摘录下面是骆驼配置的片段

<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>

我们使用no的解决方案如下:将原始消息存储在标头中并引发异常。 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}"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM