【问题标题】:Mule 3.2: How to modify the incoming SOAP payloadMule 3.2:如何修改传入的 SOAP 有效负载
【发布时间】:2012-06-21 23:25:49
【问题描述】:


我有一个关于 Mule ESB 以及如何操作对传入 SOAP 请求的响应的问题。 用例场景如下:
传入 SOAP 请求 --> 接受请求并发送到异步流进行处理 --> 在 SOAP 响应中将 Mule 事务的消息 ID 返回给调用者 -- >(继续对原始请求进行异步处理)
在这种情况下,SOAP 请求处理的结果与调用者无关。

<flow name="asyncTestFlow1" doc:name="asyncTestFlow1">
    <http:inbound-endpoint exchange-pattern="request-response"
        host="localhost" port="8088" doc:name="HTTP" />
    <logger message="F1: messageID:#[message:id]" level="INFO" />
    <async doc:name="Async">
        <flow-ref name="asyncTestFlow2" doc:name="Flow Reference" />
    </async>

    <!-- ### need to modify the request, add the message ID and send back to the client ### -->
</flow>

<flow name="asyncTestFlow2">
    <cxf:proxy-service payload="body" soapVersion="1.2" doc:name="SOAP" />
    <logger message="after cxf:proxy-service -> #[groovy:payload.getClass()]" level="INFO" />

    <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" soapVersion="1.2" doc:name="SOAP" />

    <http:outbound-endpoint exchange-pattern="request-response"
        address="http://example.net/KnowYourClient/KYCService"
        doc:name="HTTP" />

    <logger message="SOAP response: #[payload:java.lang.String]" level="INFO" />
</flow>

在第 9 行附近,我添加了一条注释,我想在其中修改请求/响应的负载。我在想我需要一个自定义消息转换器,但我不知道从哪里开始。我可以将输入作为 ContentLengthInputStream(默认传入)或 DepthXMLStreamReader(在调用 cxf:proxy-service 之后)。我认为在 XML 格式中它会更容易操作..
有人可以为我指出如何开始操作 XML 内容的正确方向吗?

谢谢你, 马库斯




--更新--现在工作的例子
我想我现在可以工作了。关键是再见数组转换器的初始对象,它允许在私有流中使用传入的消息。

<flow name="asyncTestFlow1" doc:name="asyncTestFlow1">
    <http:inbound-endpoint exchange-pattern="request-response"  host="localhost" port="8088" doc:name="HTTP" />
    <object-to-byte-array-transformer />
    <logger message="F1: messageID:#[message:id]" level="INFO" doc:name="Logger" />
    <async doc:name="Async">
        <flow-ref name="asyncTestFlow2" doc:name="Flow Reference" />
    </async>
    <custom-transformer class="org.mule.examples.hello.SoapResponseTransformer" doc:name="Java" />
</flow>

<flow name="asyncTestFlow2" doc:name="asyncTestFlow2">
    <cxf:proxy-service payload="body" soapVersion="1.2" doc:name="SOAP"/> 
    <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" soapVersion="1.2" doc:name="SOAP"/>
    <http:outbound-endpoint exchange-pattern="request-response"
        address="http://.../Service"
        doc:name="HTTP" />
    <logger message="SOAP response: #[payload:java.lang.String]" level="INFO" doc:name="Logger" />
</flow>

【问题讨论】:

    标签: soap mule


    【解决方案1】:

    您也可以使用&lt;object-to-string-transformer doc:name="Object to String"/&gt; 代替&lt;object-to-byte-array-transformer /&gt;

    【讨论】:

      猜你喜欢
      • 2012-09-18
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      • 2022-11-03
      • 1970-01-01
      • 1970-01-01
      • 2014-06-21
      • 1970-01-01
      相关资源
      最近更新 更多