i have a response from a WS in WSO2 ESB and i write this xml file on a directory on my local machine. I'd like to change the name of the .xml file according to the content. Here is the code of the sequence used for writing file:
<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>
Now i'd like to have MyFile_2.xml if I find "MyFile_2" in a particular tag of the WS response, or MyFile_3.xml if i find "MyFile_3" and so on. I think i must parameterfy my sequence, and particularly value="MyFile.xml" but i don't understand how to do.
EDIT: And what about a SOAP response? I have a SOAP answer like this:
<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>
............
I tried in a similar way, but something goes wrong when i want to call my file with MY_FILENAME inside. Previous REST response manipulation is ok, great answer Jean-Michel .
<property name="transport.vfs.ReplyFileName"
expression="concat('MyFile_',$body/root/child/text(),'.xml')" scope="transport"/>
where $body/root/child/text() is the XPath used to find your particular tag