Actually I'm trying to get an empty value when I set a Property in a sequence in WSO2 ESB with an empty string. I have tried many things but always get the result "null" or "\"\"" instead of "" when I get the property, here is my code:
<property value=""""
name="arq.general.DestinationSystem" scope="default"
type="STRING" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ns2="http://org.apache.synapse/xsd"/>
<property name="arq.general.ParentInstanceID" scope="default"
type="STRING" value=""/>
<property expression="get-property('NonExistentProperty')"
name="arq.functional.User"
scope="default" type="STRING"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ns2="http://org.apache.synapse/xsd"/>
Please could you help?
Cheers,
Tony
++ the payload Factory:
<payloadFactory media-type="xml">
<format>
<MensajeAuditoria xmlns="">
<Timestamp>$1</Timestamp>
<TrackingID>$2</TrackingID>
<SourceApplication>$3</SourceApplication>
<OperationName>$4</OperationName>
<ParentInstanceID>$5</ParentInstanceID>
<InstanceID>$6</InstanceID>
<ServiceID>$7</ServiceID>
<FunctionalID>$8</FunctionalID>
<AdapterType>$9</AdapterType>
<AdapterPoint>$10</AdapterPoint>
<HostName>$11</HostName>
<User>$12</User>
</MensajeAuditoria>
</format>
<args>
<arg evaluator="xml" expression="get-property('SYSTEM_TIME')"/>
<arg evaluator="xml" expression="get-property('arq.general.TrackingID')"/>
<arg evaluator="xml" expression="get-property('arq.general.SourceApplication')"/>
<arg evaluator="xml" expression="get-property('arq.functional.OperationName')"/>
<arg evaluator="xml" expression="get-property('arq.general.ParentInstanceID')"/>
<arg evaluator="xml" expression="get-property('arq.general.InstanceID')"/>
<arg evaluator="xml" expression="get-property('arq.general.ServiceID')"/>
<arg evaluator="xml" expression="get-property('arq.functional.FunctionalID')"/>
<arg evaluator="xml" expression="get-property('arq.general.AdapterType')"/>
<arg evaluator="xml" expression="$func:AdapterPoint"/>
<arg evaluator="xml" expression="get-property('SERVER_IP')"/>
<arg evaluator="xml" expression="get-property('arq.functional.User')"/>
</args>
</payloadFactory>
</else>
</filter>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
Adding the factory result:
{
"MensajeAuditoria": {
"Timestamp": 1492777451830,
"TrackingID": "76b9858d-8421-4d7e-d2af-e8e411382e2e",
"SourceApplication": "API Manager",
"OperationName": null,
"ParentInstanceID": null,
"InstanceID": "76b9858d-8421-4d7e-d2af-e8e411382e2e",
"ServiceID": "PRX_PROY1_AEX_AltaCliente",
"FunctionalID": null,
"AdapterType": "AEXP",
"AdapterPoint": "PreActRequest",
"HostName": "172.16.3.97",
"User": null,
}}
An other solution is to use "string" xpath function :
I have tried your payloadFactory and it turns out it works like a charm on 4.8.1 but it fails on 5.0.0. This is most likely a change in the JSON message builder that they use in the ESB. The problem is not on your empty property but in the automatic translation from XML to JSON that happens when you set the messageType property.
What you can do to solve this though is the make the payload mediator create json straight away as follows:
This way you are in control of the quotes, and it will never put null there unless you actually want it there.
Hope this helps solve your problem
I have achieved a work-around using JavaScript but it should be possible to set it in the property mediator, or may be with enrich.
If you get an XML solution, please let me know.
Thanks.