Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't apply concat function in WSO2 ESB CONFIGURATION with json-eval

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.

like image 856
FDC Avatar asked Oct 15 '25 03:10

FDC


2 Answers

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"/>
like image 198
Nicolas Avatar answered Oct 17 '25 22:10

Nicolas


You can use as below,

<property expression="json-eval($.city.name)" name="city"/>
<property expression="fn:concat($ctx:city, '.xml')" name="name-of-attribute" type="STRING" scope="default"/>

If you want to concat many parameters use as below,

<property expression="fn:concat($ctx:city ,'.', 'xml')" name="name-of-attribute" type="STRING" scope="default"/>
like image 30
Rajitha Bhanuka Avatar answered Oct 17 '25 22:10

Rajitha Bhanuka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!