i am using payloadfactory mediator and adding single slash value in arg but ESB is converting it into double slash below is the payloadfactory which in using along with response
<payloadFactory media-type="json">
<format>
{
"channel": {
"text": "this is test Text $1"
}
}
</format>
<args>
<arg evaluator="xml" value="\n" />
</args>
</payloadFactory>
Payload is set to
{
"channel": {
text": "this is test Text \\n"
}
}
and i want.
{
"channel": {
"text": "this is test Text \n"
}
}
P.S "\n" will be set above in property mediator and i will put it in payload factory through arg, thats why i cannot use it in format directly.
Thanks.
It seems to be a limitation in the ESB. Please try the following workaround. (Yeah I know. It seems like an overkill)
<enrich>
<source type="inline" clone="true">{
"replace" : "\n"
}</source>
<target type="body"/>
</enrich>
<property name="NEW_LINE" expression="json-eval($.replace)" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format> {
"channel": {
"text": "this is test Text $1"
}
}
</format>
<args>
<arg literal="true" evaluator="xml" expression="$ctx:NEW_LINE"/>
</args>
</payloadFactory>
Related
I am currently trying to create a REST API from a SOAP Endpoint using WSO2 EI.
Source system sends data in JSON format and internally we convert it to xml and send it to the destination system.
The issue we are facing here is when there is multiple data(array) which has to be sent to a single node, we are unable to achieve it. Please let us know which mediator in EI should be used along with an example if possible.
Sample SOAP Message
<fcub:Detbs-Jrnl-Txn-Detail>
<fcub:SERIAL_NO>1</fcub:SERIAL_NO>
<fcub:DR_CR>D</fcub:DR_CR>
<fcub:BRANCH_CODE>001</fcub:BRANCH_CODE>
<fcub:CCY>EUR</fcub:CCY>
<fcub:AMOUNT>20</fcub:AMOUNT>
<fcub:TXN_CODE>TOP</fcub:TXN_CODE>
<fcub:LCY_AMOUNT>20</fcub:LCY_AMOUNT>
<fcub:ADDL_TEXT>test Mjrnl</fcub:ADDL_TEXT>
<fcub:ACCOUNT>001000032027</fcub:ACCOUNT>
</fcub:Detbs-Jrnl-Txn-Detail>
<fcub:Detbs-Jrnl-Txn-Detail>
<fcub:SERIAL_NO>2</fcub:SERIAL_NO>
<fcub:DR_CR>C</fcub:DR_CR>
<fcub:BRANCH_CODE>001</fcub:BRANCH_CODE>
<fcub:CCY>EUR</fcub:CCY>
<fcub:AMOUNT>20</fcub:AMOUNT>
<fcub:TXN_CODE>TOP</fcub:TXN_CODE>
<fcub:INSTRUMENT_NO></fcub:INSTRUMENT_NO>
<fcub:LCY_AMOUNT>20</fcub:LCY_AMOUNT>
<fcub:ADDL_TEXT>test Mjrnl</fcub:ADDL_TEXT>
<fcub:ACCOUNT>110000100</fcub:ACCOUNT>
</fcub:Detbs-Jrnl-Txn-Detail>
In the above case, for <fcub:Detbs-Jrnl-Txn-Detail>, we have two sets of data with serial number 1 and serial number 2.
The corresponding JSON message will be
{
"CREATEMJRNLBOOK_IOPK_REQ": {
"FCUBS_HEADER": {
"SOURCE": "SAP_CONCUR",
"UBSCOMP": "FCUBS",
"MSGID": "TEST1234",
"USERID": "PARAMUSER3",
"ENTITY": "ENTITY_ID2",
"BRANCH": "001",
"SERVICE": "FCUBSDEService",
"OPERATION": "CreateMjrnlbook"
},
"FCUBS_BODY": {
"Detbs-Jrnl-Txn-Master-Full": {
"VALUE_DATE": "2021-07-28",
"BRANCH_CODE": "001",
"Detbs-Jrnl-Txn-Detail": [
{
"SERIAL_NO": 1,
"DR_CR": "D",
"BRANCH_CODE": "001",
"CCY": "EUR",
"AMOUNT": 20,
"TXN_CODE": "TOP",
"INSTRUMENT_NO": 0,
"LCY_AMOUNT": 20,
"ADDL_TEXT": "test Mjrnl",
"ACCOUNT": "001000032027"
},
{
"SERIAL_NO": 2,
"DR_CR": "C",
"BRANCH_CODE": "001",
"CCY": "EUR",
"AMOUNT": 20,
"TXN_CODE": "TOP",
"INSTRUMENT_NO": 0,
"LCY_AMOUNT": 20,
"ADDL_TEXT": "test Mjrnl",
"ACCOUNT": "001000032027"
}
],
"Devws-Batch-Master": {
"BALANCING": "Y"
}
}
}
}
}
Proxy.xml from EI
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="DEService" startOnLoad="true" transports="http https"
xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log description="Logger to Check JSON Message from Proxy" level="full"/>
<header description="SOAPAction" name="SOAPAction" scope="transport" value=""/>
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
<payloadFactory description="Build Request Payload" media-type="xml">
<format>
<soapenv:Envelope
xmlns:fcub="http://fcubs.ofss.com/service/FCUBSDEService"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<fcub:CREATEMJRNLBOOK_IOPK_REQ>
<fcub:FCUBS_HEADER>
<fcub:MODULEID>$1</fcub:MODULEID>
<fcub:USERID>$2</fcub:USERID>
<fcub:ACTION>$3</fcub:ACTION>
<fcub:SOURCE_OPERATION>$4</fcub:SOURCE_OPERATION>
<fcub:MSGID>$5</fcub:MSGID>
<fcub:FUNCTIONID>$6</fcub:FUNCTIONID>
<fcub:MSGSTAT>$7</fcub:MSGSTAT>
<fcub:ENTITY>$8</fcub:ENTITY>
<fcub:UBSCOMP>$9</fcub:UBSCOMP>
<fcub:OPERATION>$10</fcub:OPERATION>
<fcub:BRANCH>$11</fcub:BRANCH>
<fcub:MULTITRIPID>$12</fcub:MULTITRIPID>
<fcub:SNAPSHOTID>$13</fcub:SNAPSHOTID>
<fcub:SERVICE>$14</fcub:SERVICE>
<fcub:SOURCE>$15</fcub:SOURCE>
<fcub:PASSWORD>$16</fcub:PASSWORD>
<fcub:CORRELID>$17</fcub:CORRELID>
<fcub:DESTINATION>$18</fcub:DESTINATION>
<fcub:SOURCE_USERID>$19</fcub:SOURCE_USERID>
</fcub:FCUBS_HEADER>
<fcub:FCUBS_BODY>
<fcub:Detbs-Jrnl-Txn-Master-Full>
<fcub:VALUE_DATE>$20</fcub:VALUE_DATE>
<fcub:BRANCH_CODE>$21</fcub:BRANCH_CODE>
<fcub:Detbs-Jrnl-Txn-Detail>
<fcub:SERIAL_NO>$22</fcub:SERIAL_NO>
<fcub:DR_CR>$23</fcub:DR_CR>
<fcub:BRANCH_CODE>$24</fcub:BRANCH_CODE>
<fcub:CCY>$25</fcub:CCY>
<fcub:AMOUNT>$26</fcub:AMOUNT>
<fcub:TXN_CODE>$27</fcub:TXN_CODE>
<fcub:LCY_AMOUNT>$28</fcub:LCY_AMOUNT>
<fcub:ADDL_TEXT>$29</fcub:ADDL_TEXT>
<fcub:ACCOUNT>$30</fcub:ACCOUNT>
</fcub:Detbs-Jrnl-Txn-Detail>
<fcub:Devws-Batch-Master>
<fcub:BALANCING>$31</fcub:BALANCING>
</fcub:Devws-Batch-Master>
</fcub:Detbs-Jrnl-Txn-Master-Full>
</fcub:FCUBS_BODY>
</fcub:CREATEMJRNLBOOK_IOPK_REQ>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.MODULEID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.USERID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.ACTION"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.SOURCE_OPERATION"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.MSGID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.FUNCTIONID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.MSGSTAT"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.ENTITY"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.UBSCOMP"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.OPERATION"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.BRANCH"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.MULTITRIPID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.SNAPSHOTID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.SERVICE"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.SOURCE"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.PASSWORD"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.CORRELID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.DESTINATION"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_HEADER.SOURCE_USERID"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.VALUE_DATE"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.BRANCH_CODE"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.SERIAL_NO"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.DR_CR"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.BRANCH_CODE"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.CCY"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.AMOUNT"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.TXN_CODE"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.LCY_AMOUNT"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.ADDL_TEXT"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Detbs-Jrnl-Txn-Detail.ACCOUNT"/>
<arg evaluator="json" expression="$.CREATEMJRNLBOOK_IOPK_REQ.FCUBS_BODY.Detbs-Jrnl-Txn-Master-Full.Devws-Batch-Master.BALANCING"/>
</args>
</payloadFactory>
<property description="messageProperty" name="messageType" scope="axis2" type="STRING" value="application/soap+xml"/>
<property description="ContentType" name="ContentType" scope="axis2" type="STRING" value="text/xml"/>
<log description="Logger to check XML Message" level="full"/>
<send>
<endpoint key="FCUBSDEService_ADDRESS_EP"/>
</send>
</inSequence>
<outSequence>
<property description="Convert XML to Payload" name="messageType" scope="axis2" type="STRING" value="application/json"/>
<log description="Logger to Check Payload Response" level="full"/>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
Please let us know how to achieve this using EI.
Thanks
Tandon
For that You should use Iterate mediator, described in this documentation. Look at this XPath example.
But described by you JSON example, is not valid, because it should contain Array as Detbs-Jrnl-Txn-Detail. Its would be easier if i can see more msg context.
I have a below request (i am using WSO2 Enterprise integrator 6.5.0):
And I wanna get this in jsonpayload which is returned client
<ERROR_RESP>
<ERROR>
<ECODE>ST-VALS-002</ECODE>
<EDESC>Record Not Found for Branch Code-CHO:Currency 1-USD:Currency 2-MN</EDESC>
</ERROR>
<ERROR>
<ECODE>ST-SAVE-024</ECODE>
<EDESC>Failed to Query Data</EDESC>
</ERROR>
</ERROR_RESP>
It is my tried code to achieve it :
<foreach expression="json-eval($.ERROR_RESP.ERROR)">
<sequence>
<payloadFactory media-type="json">
<format>
{
"ErrorCode" : "$1",
"ErrorMessage" : "$2"
}
</format>
<args>
<arg evaluator="json" expression="$.ECODE"/>
<arg evaluator="json" expression="$.EDESC"/>
</args>
</payloadFactory>
<log level="full">
<property name="MESSAGE" value="ENDLOOP"/>
</log>
<loopback/>
</sequence>
</foreach>
enter code here
I did some search but nothings worked, I think foreach expression is not right.
Thanks
Regards,
In your sample the Loopback mediator is used. It will be used to move the message to the out flow (response path). Therefore, the Foreach mediator splits the message and sends the first message to the response path and end the flow.
You can prepare the XML payload and convert it to JSON using the messageType property with axis2 scope as follows.
<foreach expression="//ERROR">
<sequence>
<payloadFactory media-type="xml">
<format>
<ERROR xmlns="">
<ErrorCode>$1</ErrorCode>
<ErrorMessage>$2</ErrorMessage>
</ERROR>
</format>
<args>
<arg evaluator="xml" expression="//ECODE/text()"/>
<arg evaluator="xml" expression="//EDESC/text()"/>
</args>
</payloadFactory>
</sequence>
</foreach>
<property name="messageType" scope="axis2" value="application/json"/>
The final message will be like this:
{
"ERROR_RESP": {
"ERROR": [
{
"ErrorCode": "ST-VALS-002",
"ErrorMessage": "Record Not Found for Branch Code-CHO:Currency 1-USD:Currency 2-MN"
},
{
"ErrorCode": "ST-SAVE-024",
"ErrorMessage": "Failed to Query Data"
}
]
}
}
At the moment, foreach mediator in EI 6.5.0 does not support "json-eval()" expressions. This feature will be included in the upcoming versions.
As a workaround, you can use XPath inside the expression. You can use this blog as an example. https://medium.com/#Manuri/wso2-esb-foreach-mediator-example-87f041e2a912
I'm trying to create Message Mediation Policies, with which I can make an additional http call, process the response and enrich the current message. How can i do this? I use call Mediator, but I don’t understand how to handle the response.
<?xml version="1.0" encoding="UTF-8"?> <sequence name="call_out_handler" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<call blocking="true">
<endpoint>
<http method="get" uri-template="http://192.168.99.100:8888/stubFORAPIMan/ServletWithTimeout"/>
</endpoint>
</call> </sequence>
You can use the PayloadFactory Mediator [1] to handle/format the response you received by calling an endpoint inside the Call mediator.
An example would be like this. Say you want to provide a json object by populating the values from the response you received; you can define the json object format in the "format" section and populate the values by providing the arguments in the "args" section in the PayloadFactory mediator as below.
<payloadFactory media-type="json">
<format>
{
"Data": {
"PaymentSubmissionId": "$1",
"PaymentId": "$2",
"Status": "$3",
"CreationDateTime": "$4"
}
}
</format>
<args>
<arg evaluator="xml" expression="$body//PaymentSubId"/>
<arg evaluator="xml" expression="$body//PaymentId"/>
<arg evaluator="xml" value="AcceptedSettlementInProcess"/>
<arg value="2019-06-05T15:15:22+00:00"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
[1] https://docs.wso2.com/display/EI640/PayloadFactory+Mediator
In this case, how can I get the "MyString" content in WSO2 response?
Request:
<payloadFactory media-type="json">
<format>{
"Name" : "$1",
"group": "$3"
}
</format>
<args>
<arg evaluator="xml" expression="$ctx:Name"/>
<arg evaluator="xml" expression="$ctx:group"/>
</args>
</payloadFactory>
<call>
<endpoint key="ep_Server"/>
</call>
response:
Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><text xmlns="http://ws.apache.org/commons/ns/payload">{"MyString":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjEsIlN5c3RlbUlkIjoyMSwiUHJvcGVydHlJZCI6OSwiSXNBZG1pbiI6ZmFsc2UsIkNyZWF0ZURhdGVUaW1lIjoiMjAxNy0xMS0wOFQxMDoyMjoxMi45MDA3MjE4KzA4OjAwIn0.k6FyUGwXOAeC63oGsPWz8ttwo1LeDG3vnTbw7dJ18GY"}</text></soapenv:Body></soapenv:Envelope>
Try this.
<log>
<property name="MyString" expression="json-eval($.MyString)"></property>
</log>
Ref: https://docs.wso2.com/display/ESB500/JSON+Support
In your case the output is not json it's xml containing a text, usually it indicate that you're using text/plain type, I think the issue is there.
Moreover your output is not matching the sample code you've
Could you try to put the following before your call:
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
What is the content type that the service you're calling is returning? Is it valid? If not it could be that wso2 ei is by default considering it's text
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,
}}
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.
<script language="js"><![CDATA[var payload = mc.getPayloadJSON();
if(payload.MensajeAuditoria.ParentInstanceID== null){
payload.MensajeAuditoria.ParentInstanceID="";
}
mc.setPayloadJSON(payload);
mc.setProperty("MyProperty","");]]></script>
If you get an XML solution, please let me know.
Thanks.
An other solution is to use "string" xpath function :
<property name="arq.general.ParentInstanceID" expression="string('')"/>
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:
<payloadFactory media-type="json">
<format>
{"MensajeAuditoria":{
"Timestamp":$1,
"TrackingID":"$2"
...
}
}
</format>
<args>
<arg evaluator="xml" expression="get-property('SYSTEM_TIME')"/>
<arg evaluator="xml" expression="get-property('arq.general.TrackingID')"/>
...
</args>
</payloadFactory>
</else>
</filter>
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
Good thing would be to use enrich mediator to map the json field to xml field if there is a vale for the incoming field.
Sample
<filter regex="true" source="boolean(get-property('START_DATE'))">
<then>
<enrich description="Add startDate tag">
<source clone="true" type="inline">
<org:startDate xmlns:org="urn:example.com/service/org"/>
</source>
<target action="child" xpath="//*[local-name()=get-property('RequestType')]"/>
</enrich>
<enrich description="populate startDate">
<source clone="true" property="START_DATE" type="property"/>
<target
xmlns:org="urn:example.com/servi`enter code here`ce/org" xpath="//org:startDate"/>
</enrich>
</then>
<else/>
</filter>