3

我得到一个文件路径作为 xml 中 mule 的输入。使用 XPATH 表达式,我能够提取路径。我想从该路径读取特定文件。我尝试如下定义文件入站端点。但这似乎不起作用。

    <flow name="flow1">
     ....
     ....
    <set-session-variable variableName="filePath" value="#[xpath://filePath]" />
    <flow-ref name="fileFlow"/>
    </flow>

    <flow name="fileFlow">
    <file:inbound-endpoint path="#[header:SESSION:filePath]" />
    </flow>

我的理解是在入站端点之前不能放置任何代码。因此,我在另一个流程中定义了它。请建议是否有办法从指定路径读取文件。

4

1 回答 1

4

不幸的是,您不能以编程方式调用这样的入站端点。

然而,使用 Mule 请求者模块可以实现相同的功能:

例子:

  <flow name="RequestFile" doc:name="RequestFile">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="requestfile" doc:name="HTTP"/>
        <mulerequester:request config-ref="Mule_Requester" resource="file:///s/tmp/demorequester/read/#[message.inboundProperties['filename']]" returnClass="java.lang.String" doc:name="Request a file"/>
    </flow>

此处的说明:https ://github.com/mulesoft/mule-module-requester和https://blogs.mulesoft.com/dev/mule-dev/introducing-the-mule-requester-module/

于 2014-02-07T20:03:13.550 回答