【问题标题】:Changing filename in WSO2 ESB according to ws response根据 ws 响应更改 WSO2 ESB 中的文件名
【发布时间】:2016-01-19 00:09:23
【问题描述】:

我收到了来自 WSO2 ESB 中 WS 的响应,我将此 xml 文件写入本地计算机上的目录中。我想根据内容更改.xml文件的名称。以下是用于写入文件的序列代码:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="WriteFile">
<property name="transport.vfs.ReplyFileName" value="MyFile.xml" scope="transport"></property>
<property name="OUT_ONLY" value="true"></property>
<send>
  <endpoint>
     <address uri="vfs:file:///C:\MyFolder"></address>
  </endpoint>
</send>
</sequence>

现在,如果我在 WS 响应的特定标记中找到“MyFile_2”,我想要 MyFile_2.xml,或者如果我找到“MyFile_3”,则使用 MyFile_3.xml,依此类推。我想我必须参数化我的序列,特别是 value="MyFile.xml" 但我不明白该怎么做。

编辑:那么 SOAP 响应呢?我有一个这样的 SOAP 答案:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap..............>
<soap:Body>
  <QueryStructureResponse xmlns="..........>
     <QueryStructureResult>
        <RegistryInterface xmlns="ht............>
           <Header>
              <ID>IT1001</ID>
              <Test>true</Test>
              <Name xml:lang="en">MY_FILENAME</Name>
               ............

我以类似的方式尝试过,但是当我想调用包含 MY_FILENAME 的文件时出现问题。 以前的 REST 响应操作没问题,Jean-Michel 的回答很好。

【问题讨论】:

    标签: wso2 response sequence wso2esb transport


    【解决方案1】:
    <property name="transport.vfs.ReplyFileName"
    expression="concat('MyFile_',$body/root/child/text(),'.xml')" scope="transport"/>
    

    其中 $body/root/child/text() 是用于查找特定标签的 XPath

    【讨论】:

    • JSON 响应怎么样?它适用于 XML 响应,但我无法从 JSON 中提取文本...我尝试使用 goessner.net/articles/JsonPath 但没有
    • 在表达式中使用 json-eval(),例如 concat('MyFile_',json-eval($.elmt1.child1), '.xml')。见docs.wso2.com/display/ESB481/JSON+Support
    • 我正在尝试以这种方式使用 json-eval: concat('Meteo_',json-eval($.city.name),'.xml') 但 wso2 esb 不保存这个配置,我不能在“表达式”字段中插入这个。如果有用,我可以提出一个新问题以了解更多详细信息
    猜你喜欢
    • 1970-01-01
    • 2016-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-18
    • 2015-02-27
    相关资源
    最近更新 更多