The CreatorCon Call for Content is officially open! Get started here.

Parsing XML Response

mdidrikson
Kilo Contributor

Hello,

I have a business rule that makes a call to an external web service and receives an XML response. The response document returned is quite large (see attached document). I am having some issues parsing this XML document. Here is the code that I am using to parse the response document:



var response = request.getResponseDoc();
gs.log("Get Tickets response from Savvis: " + response);

gs.log("Parse the response");

//PARSE THE RESPONSE
try {
var savvisXML = new XMLDocument(response);
} catch (e) {
gs.log("Error parsing XML response from Savvis: " + e.toString());
}

I am receiving the following error:

Error parsing XML response from Savvis: java.lang.NullPointerException

My guess is the issue is with the

<![CDATA[
tags in the response document. If I make this call and these fields are not included, I am able to parse the document.

Couple of questions I have:

1. Is there a way to parse an XML document that contains the

<![CDATA[
tags?
2. Is there a good way to loop through a large XML document such as this one? I would like to grab the "key" and "value" elements from this document.

Thanks for your help!

Mark Didrikson

18 REPLIES 18

Mark,

Either the CDATA tag is getting stripped off somehow, or something is happening to the string before it is printed to the log. I would try to narrow down to the point where the CDATA tag goes missing.

-John



john.andersen


John,

I am writing the XML response to the log file as soon as I receive it and the CDATA tags are missing.



var response = request.getResponseDoc();
gs.log("GET TICKET response from Savvis: " + response);


Do you know if Service-Now does something with the CDATA tags? Strip them out or something? I see the CDATA tags in my response if I use SOAP UI.

Thanks.

Mark


Are you getting the SOAP Response from the ECC Queue table? If so, I have heard of some people experiencing an issue where the CDATA was getting stripped when coming into the ECC Queue.

-John


Hi,

We're getting the SOAP response from an external source, a vendor's web service

Thanks.

Mark