如何在m子中手动引发肥皂故障 [英] How to throw Soap Fault manually in mule

查看:55
本文介绍了如何在m子中手动引发肥皂故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临着无法使用架构验证传入请求的情况(基本上存在架构,但是它可以接受请求中的任何String,wsdl设计人员有其自己的理由来接受来自不同来源和灵活性的请求) .但是,当收到请求时,我验证了请求包装的子元素是否符合我们的期望(为此使用了XPath).现在,如果子元素不是预期的,我想用Client代码抛出Soap Fault,并且可能包含错误消息,表明架构验证失败,请求不包含有效元素.

I'm face with a situation where we cannot use schema to validate incoming request (basically schema is there but it accepts any String in request, wsdl designers have their own reasons to do that to accept request from different sources and flexibility). But when the request is received, I validate that the child element of request wrapper is what we expect (using XPath for that). Now if the child element is not what expected, I'd like to throw Soap Fault with Client code and may be include error message that schema validation failed, request doesn't contain valid element.

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

I'm using Mule 3.3 and doing my XPath validation in <choice> element and I want to throw exception in <otherwise> block.

  1. 有没有办法在m子流和
  2. 中手动抛出Soap Fault
  3. 如何添加自定义故障字符串.我不确定outInterceptor是否会解决问题,因为我没有使用<cxf:proxyService>schemaValidation属性.
  1. Is there a way to throw Soap Fault manually in mule flow and
  2. How to add custom fault string. I'm not sure if an outInterceptor will solve the purpose as I'm not using schemaValidation attribute of <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>

推荐答案

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

Since you are using a cxf:proxy-service you have complete control on the response. For example, if you add the following in your otherwise block, you'll be able to create whatever SOAP fault you want:

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

这篇关于如何在m子中手动引发肥皂故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆