简体   繁体   English

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

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

The following scenario was working with apache camel 2.14.0, spring-ws 1.5.9 and axiom 1.2.9 以下场景适用于Apache骆驼2.14.0,spring-ws 1.5.9和公理1.2.9

Scenario - When our soap service is called, it should optional return an error - This error should be in the response as soap fault 场景 -调用我们的soap服务时,它应该可选地返回一个错误-此错误应作为soap错误在响应中

Problem detection 问题检测

I already detected the problem: - The org.springframework.ws.soap.axiom.AxiomHandler(2.3.0) of Spring-WS does not create SOAPFault objects - The org.apache.axiom.soap.impl.llom.SOAPBodyImpl (1.2.15) no longer checks the local name of the element 我已经检测到问题:-Spring-WS的org.springframework.ws.soap.axiom.AxiomHandler(2.3.0)不会创建SOAPFault对象-org.apache.axiom.soap.impl.llom.SOAPBodyImpl(1.2 .15)不再检查元素的本地名称

Question It there a better way to handle the soap faults with apache camel? 问题是否有更好的方法来处理apache骆驼的肥皂毛病?

  • One possibility is to use throwException but than my log will contain a lot of stacktrace in case of a functional error 一种可能性是使用throwException,但是如果发生功能错误,我的日志将包含很多stacktrace

Snippet Below is snippet of the camel configuration 摘录下面是骆驼配置的片段

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

The solution we're using no, is the following: Store the original message in the header and throw an exception. 我们使用no的解决方案如下:将原始消息存储在标头中并引发异常。 The spring-ws component will automatically transform it to a soap fault. spring-ws组件将自动将其转换为肥皂故障。 Also add the CamelFailuerHandled so that the error message is not within the log files. 还添加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