来自vfs文件的

时间:2017-06-09 18:00:43

标签: loops wso2 vfs

我在VFS上使用WSO2。我需要获取传入的文件 fileinput.xml 并将 id 字段记录在一起。 VFS已启用且功能正常,当我将fileinput.xml移动到 test_in 文件夹中时,它会被正确处理并正确放入 test_out test_failure 。我已经阅读了很多在线文档,但无法解决如何执行以下操作的问题。

我的问题是

  1. 如何从 fileinput.xml 获取属性?
  2. 如何迭代id并在日志中将它们连接在一起?
  3. fileinput.xml

    <soapenv:Envelope
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header/>
        <soapenv:Body>
            <customers>
                <customer>
                    <id>testid1</id>
                    <prop1>a</prop1>
                    <prop2>b</prop2>
                <customer/>
                <customer>
                    <id>testid2</id>
                    <prop1>3</prop1>
                    <prop2>4</prop2>
                <customer/>
            </customers>
        </soapenv:Body>
    </soapenv:Envelope>
    

    我的wso2代理文件

    <?xml version="1.0" encoding="UTF-8"?>
    <proxy
        xmlns="http://ws.apache.org/ns/synapse" name="FileProxy" transports="vfs" startOnLoad="true" trace="disable">
        <target>
            <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
            <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
            <parameter name="transport.PollInterval">5</parameter>
            <parameter name="transport.vfs.FileURI">file:///Users/myuser/test_in</parameter>
            <parameter name="transport.vfs.MoveAfterProcess">file:///Users/myusertest_out</parameter>
            <parameter name="transport.vfs.MoveAfterFailure">file:///Users/myuser/test_failure</parameter>
            <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
            <parameter name="transport.vfs.ContentType">text/xml</parameter>
            <inSequence>
                <log category="WARN" level="full">
                    <property name="MESSAGE" value="In Sequence"/>
                </log>
                <clone>
                    <target sequence="fileWriteSequence"/>
                </clone>
            </inSequence>
        </target>
        <outSequence>
            <log category="WARN" level="full">
                <property name="MESSAGE" value="Out Sequence"/>
            </log>
            <send/>
        </outSequence>
    </proxy>
    

    我的fileWriteSequence

    <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="fileWriteSequence">
        <log level="full">
            <property name="sequence" value="fileWriteSequence"/>
        </log>
        <property name="transport.vfs.ReplyFileName" expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.txt')" scope="transport"/>
        <property name="OUT_ONLY" value="true"/>
        <send>
            <endpoint name="FileEpr">
                <address uri="vfs:file:///Users/myuser/test_out"/>
            </endpoint>
        </send>
    </sequence>
    

1 个答案:

答案 0 :(得分:1)

您可以使用iterate mediator迭代“id”。元素并使用操作范围中的属性来连接所有id值。请参阅this