2015-10-20 63 views
1

我在WSO2 ESB中有一个来自WS的响应,我在本地机器上的一个目录中写入这个xml文件。我想根据内容更改.xml文件的名称。下面是序列用于写文件的代码:根据ws响应在WSO2 ESB中更改文件名

<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> 

现在我想有MyFile_2.xml如果我找到“MyFile_2”在WS响应的特定标签,或MyFile_3.xml如果我找到“MyFile_3”等等。我想我必须参数化我的序列,特别是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很好的回答。

回答

3
<property name="transport.vfs.ReplyFileName" 
expression="concat('MyFile_',$body/root/child/text(),'.xml')" scope="transport"/> 

其中$体/根/儿童/文()是XPath用来寻找您的特定标签

+0

没关系,谢谢你 – FDC

+0

什么JSON响应?它与XML响应正常工作,但我无法从JSON中提取我的文本...我尝试过http://goessner.net/articles/JsonPath/,但没有任何 – FDC

+0

在您的使用中使用json-eval()表达式,像concat('MyFile _',json-eval($。elmt1.child1),'.xml')。请参阅https://docs.wso2.com/display/ESB481/JSON+Support –