atom feed15 messages in org.apache.ws.synapse-devRE: Does CData work ?
FromSent OnAttachments
kimhornApr 14, 2009 9:28 pm 
Kim HornApr 14, 2009 9:32 pm 
Andreas VeithenApr 15, 2009 1:12 am 
kimhornApr 15, 2009 2:08 pm 
Andreas VeithenApr 16, 2009 2:41 pm 
kimhornApr 16, 2009 5:34 pm 
Andreas VeithenApr 17, 2009 1:08 am 
Andreas VeithenApr 18, 2009 5:44 am 
kimhornApr 19, 2009 3:18 pm 
Andreas VeithenApr 20, 2009 12:16 am 
Kim HornApr 26, 2009 8:12 pm 
Kim HornApr 26, 2009 9:11 pm 
Andreas VeithenMay 5, 2009 8:24 am 
Kim HornMay 5, 2009 11:32 pm 
kimhornMay 11, 2009 11:53 pm 
Subject:RE: Does CData work ?
From:Kim Horn (kim.@icsglobal.net)
Date:Apr 14, 2009 9:32:25 pm
List:org.apache.ws.synapse-dev

Note prior message will not view correctly on Web as the escaped data gets interpreted and un-escaped. Appears OK in an email.

-----Original Message----- From: kimhorn [mailto:kim.@icsglobal.net] Sent: Wednesday, 15 April 2009 2:29 PM To: de@synapse.apache.org Subject: Does CData work ?

We have a target service that requires a CDATA wrapped tag as the text can have leading and/or trailing spaces. I have attemped to use a Java Mediator to wrap the data, in a property, with CData. The property is then imbedded into XML payload using Javascript, see below. Extract of Java:

claimData = "<![CDATA[\"" + claimData + "\"]]>"; synCtx.setProperty("claimData", claimData);

Note the " are required to delimit the data for the receiver. However using TCPMON the data actually sent is:

<ws1:responseFormat>997</ws1:responseFormat> <ws1:claimData>&lt;![CDATA["000000221933601MOHMCRYBA000000022193 etc etc ......

The recipient service does not like this. Synapse escapes the "<" . I was hoping to get:

<ws1:responseFormat>997</ws1:responseFormat> <ws1:claimData><![CDATA["000000221933601MOHMCRYBA000000022193 etc etc ......

It appears betwen the mediator and send, the XML gets weird. After the mediator I am using JavaScript to add the property into the XML payload, see {claimData}:

<script language="js"><![CDATA[var guid = mc.getProperty("GUID").toString(); var claimData = mc.getProperty("claimData").toString(); var fileName = mc.getProperty("fileName").toString(); mc.setPayloadXML(<ws1:submitHealthCareClaimBatch xmlns:ws1="http://ws1.thelma.icsglobal.net"> <ws1:guid>{guid}</ws1:guid>

<ws1:clientBatchId>{guid}</ws1:clientBatchId> <ws1:claimFormat>NDC</ws1:claimFormat>

<ws1:responseFormat>997</ws1:responseFormat>

<ws1:claimData>{claimData}</ws1:claimData> </ws1:submitHealthCareClaimBatch>); ]]></script>

Is the Javascript the problem ? Note it is impossible to insert the CDATA in the Javascript as then the Javscript become invalid due to the nested CDATA. Hence why I used Java.

If I do all the above in Java, create the payload in Java and wrap the tag in "<![CDATA[\"" + claimData + "\"]]>" in Java, instead of Javascript, is this likely to work, or is it the synapse send process escaping the CDATA XML ?

Thanks