问题
I'm trying to set this expression in order to obtain the output file name as a concat between the name of the city and the extention of the file:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="WriteFile_City" xmlns="http://ws.apache.org/ns/synapse">
<property expression="concat(json-eval($.city.name),'.xml')"
name="transport.vfs.ReplyFileName" scope="transport"
type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint>
<address uri="vfs:file:///C:/myFolder"/>
</endpoint>
</send>
</sequence>
If I only try to insert the name of the city, it works: the third line would be
<property expression="json-eval($.city.name)"
and in this way i save my output in a file named "London", for example. But i need to save output as "London.xml", but i can't understand where is the problem with this concat function.
回答1:
did you tried fn:concat(json-eval($.city.name),'.xml') instead of simply concat(....) ? I know that I already add issue when using functions with some expression. I generally also try to first declare a property and then use it like
<property expression="json-eval($.city.name)" name="city"/>
<property expression="concat(get-property('city'),'.xml')"
name="transport.vfs.ReplyFileName" scope="transport"
type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
回答2:
there, the right way is:
<property expression="fn:concat(get-property('city'),'.xml')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
来源:https://stackoverflow.com/questions/41631258/cant-apply-concat-function-in-wso2-esb-configuration-with-json-eval