Showing posts with label ESQL. Show all posts
Showing posts with label ESQL. Show all posts

Monday, April 3, 2017

How to Pass Null Value in JSON Message using ESQL

Input Message

<XML>
<Message>
<Name></Name>
</Message>
</XML>


Now if you need to send Name as Null to output message . Use the following esql.

Set outputroot.json.data.message.name Value = Nullif(Inputroot.XMLNC.XML.Message.Name,'')





Sunday, June 21, 2015

How To Add CDATA Section in XML using ESQL

CDATA - CDATA is a property which we can use to transport any type of data lets say XML which is not formatted properly ie.

C Data tells XML parser not to parse the XML (data) inside these tags , A CDATA section starts with "<![CDATA[" and ends with "]]>" in Message broker or IIB we can achieve this using below code


DECLARE requestBlob BLOB ASBITSTREAM(outRef,OutputRoot.Properties.Encoding,OutputRoot.Properties.CodedCharSetId);
        DECLARE requestChar CHAR CAST(requestBlob AS CHARACTER CCSID OutputRoot.Properties.CodedCharSetId);
        DELETE FIELD OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ser:serviceCall.xsd:requestBody.xsd:request;
        SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.ser:serviceCall.xsd:requestBody.(XMLNSC.CDataField)xsd:request = requestChar;


The output of above ESQL will be like below

<NS3:requestBody xmlns:NS3="example.com">
                    <NS3:request>
                        <![CDATA[<RequestXml><TxnRefNo>12342233</TxnRefNo><other data></RequestXml>]]></NS3:request>
                </NS3:requestBody>


By looking at above example you can format your ESQL, hope this help you, do let me know in comment if any further queries in the comment section below. Enjoy.