【问题标题】:How to create a soap fault with apache camel spring-ws如何使用 apache camel spring-ws 创建一个肥皂故障
【发布时间】:2017-10-12 13:03:08
【问题描述】:

以下场景使用 apache camel 2.14.0、spring-ws 1.5.9 和 axiom 1.2.9

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

问题检测

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

问题 有没有更好的方法来处理 apache camel 的肥皂故障?

  • 一种可能性是使用 throwException,但如果出现功能错误,我的日志将包含大量堆栈跟踪

片段 下面是骆驼配置的sn-p

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

【问题讨论】:

    标签: apache-camel spring-ws axiom


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多