如何在mule中手动抛出Soap Fault

Cha*_*ana 3 soap cxf mule

我面临的情况是我们不能使用模式来验证传入的请求(基本上架构在那里,但它接受请求中的任何字符串,wsdl设计者有自己的理由来接受来自不同来源的请求和灵活性).但是当收到请求时,我验证请求包装器的子元素是我们期望的(使用XPath).现在,如果子元素是不是有什么期望,我想抛出Soap FaultClient代码,并且可包括架构验证失败,请求不包含有效的元素错误信息.

我正在使用Mule 3.3并XPath<choice>元素中进行验证,我想在<otherwise>块中抛出异常.

  1. 有没有办法Soap Fault手动投掷骡子流和
  2. 如何添加自定义故障字符串.我不确定是否outInterceptor会解决目的,因为我没有使用schemaValidation属性<cxf:proxyService>.

这是我流程的一部分

<http:inbound-endpoint address="${service.address}" exchange-pattern="request-response">
  <cxf:proxy-service wsdlLocation="classpath:service.wsdl" namespace="http://company.com/services/service" service="CompanyService" />
</http:inbound-endpoint>
<choice>
  <when>.....</when>
  <otherwise><!-- Here I want to throw Soap Fault ---></otherwise>
</choice>
<catch-exception-strategy>
  <flow-ref name="generateErrorResponse" />
</catch-exception-strategy>
Run Code Online (Sandbox Code Playgroud)

Dav*_*sot 6

由于您正在使用a,因此cxf:proxy-service您可以完全控制响应.例如,如果在otherwise块中添加以下内容,则可以创建所需的任何SOAP错误:

<expression-component><![CDATA[
 message.payload = '<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
                 + '<faultcode>A code</faultcode><faultstring>A string</faultstring>'
                 + '</soap:Fault>';
]]></expression-component>
Run Code Online (Sandbox Code Playgroud)