We have request XML containing CDATA in its payload. When I use XML data protocol or Generic XML Data protocol, CDATA section comes as a single argument in the VSI. Our requirement is to get each node of CDATA as separate arguments in VSI.If anyone has tried this scenario, please let us know the solution.
Did you try 'request data manager' protocol and try fetching arguments/fields you want ?
Not sure if you solved your issue. You could do this with a Scriptable DPH or a Custom DPH.
- Get the body of the request as string
- use String's replaceAll method to remove the CDATA tags
... = yourString.replaceAll("<\\!\\[CDATA\\[", "");
... = yourString.replaceAll("\\]\\]>", "");
... = yourString.replaceAll("<", "<"); // incase cdata is encoded
Substring the converted string in place of your CDATA or set the converted string into the body (lisa_vse_request.setBody( yourString) if you do not need the surrounding XML. This of course depends on your requirement.
NOTE: If the XML in the CDATA has a <!doctype> declaration, remove it using substring.
Add the Scriptable DPH before the XML SOAP, Generic XML, RDM, XML DPH, etc. so your Arg List builds out to include the elements in your CDATA or play around with the order and type of XML parsers to get the desired Arg List.
Thank you very much for your guidance. We tried it using Scriptable DPH ad it worked for us.
Glad to hear that you got it working.
In case others look at this thread, additionally remove the XML declaration (<?xml version="1.0" ?>) if it exists in your CDATA or your parser will throw an exception. XML declarations should occur once on the outer XML.