【问题标题】:Mule ESB How to dump POST payload to a fileMule ESB 如何将 POST 有效负载转储到文件
【发布时间】:2013-10-28 19:56:20
【问题描述】:

我开始使用 Mule ESB。我正在尝试构建一个接收 SOAP 请求并将其重定向到 SOAP 服务的 SOAP 代理服务。

这样一个简单的例子就可以正常工作 -

<flow name="http_redirectFlow1" doc:name="http_redirectFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8092/HelloProxyService" doc:name="HTTP"/>
    <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/soapsvc/hello" contentType="text/xml" doc:name="HTTP"/>
</flow>

现在我想将请求的内容转储到文件中。最好的方法是什么?我尝试通过在入站和出站端点之间插入此段来使用文件连接器 -

    <file:outbound-endpoint path="c:/temp" outputPattern="temp.txt" responseTimeout="10000" doc:name="File"/>

但这似乎不起作用。我收到一个异常,上面写着“必须在写入实体之前设置内容”。不知道它是什么,但我的行为可能完全错误。请帮忙....

【问题讨论】:

    标签: soap mule esb


    【解决方案1】:

    我自己想出来的。我必须使用 dom-to-xml 转换器将 DOM 转换为 XML。 XML 转储如下完成:-

    <mulexml:dom-to-xml-transformer returnClass="java.lang.String"></mulexml:dom-to-xml-transformer>
    <file:outbound-endpoint path="c:/temp" outputPattern="Dump_Rcvd.txt" responseTimeout="10000" doc:name="File" />
    

    谢谢!

    【讨论】:

    • 接受答案,这样论坛未回答的问题百分比就会减少。
    【解决方案2】:

    或者,您可以在file:outbound-endpoint 之前使用&lt;object-to-string-transformer doc:name="Object to String"/&gt;,这将使有效负载成为字符串格式并且可以轻松写入文件

    【讨论】:

      【解决方案3】:

      使用涉及 Bytearray 的文件连接器和转换器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-20
        • 2017-10-23
        • 1970-01-01
        • 2014-11-30
        相关资源
        最近更新 更多