Parsing XML Response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2010 08:22 AM
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
tags in the response document. If I make this call and these fields are not included, I am able to parse the document.
<![CDATA[
Couple of questions I have:
1. Is there a way to parse an XML document that contains the
tags?
<![CDATA[
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
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2010 12:04 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2010 10:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2010 10:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2010 10:58 AM
Hi,
We're getting the SOAP response from an external source, a vendor's web service
Thanks.
Mark