Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

"GET XML Document Data" return null

Hello

I have a XML document with the following content

<storeInfo>

      <storeID>424</storeID>

      <storeType>Main</storeType>

</storeInfo>

My two GET XML Document Data steps look like this "//descendant::storeInfo/child::storeType" and "//descendant::storeInfo/child::storeID". Both return null. Any suggestion on why they are returning null when there is information.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

You are correct...Cisco's XML

You are correct...Cisco's XML parser (I believe its SAXv1..which some of its "parts" are deprecated by SAXv2) does not handle namespaces and other artifacts inside XML very well. And yes Greg is the man..I am Sam though..and I will be your man today and keep it really simple..but first you are going to have to Open a Curly Brace for me.

Go ahead and continue to use the Create XML Document Step..but instead of using the Get XML Data grab a Do Step and paste the code that I have here including the { } then apply and run the code...(ensuring the name of the String(s) I have defined here are the same as what you have..So..I am still getting used to the new styles in this forum..so I'm going to show a screenshot of what the code looks like and I'll attach a text file of code you can copy and paste..Just FYI, I updated the TXT File to Include TRY/CATCH block..because some of the activity going on in this code can Throw Exceptions (crash your program)...Not Captured in this Screenshot..

Can you repost the entire XML

Edit: Try the Follow where I told you previously (soapResponseDoc); The resulting Document in your Create XML Document Step is the one listed below:

org.w3c.dom.Document domDoc = builder.parse(SOAPResponseXML)

Can you repost the entire XML Document? The one you previously posted was not a wellformed XML Document:

<?xml version="1.0"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><?xml version="1.0" encoding="UTF-8"?>

 

Adding another screenshot of a snippet of how I'm interpreting what you are doing with debug and return values of code:

18 REPLIES
New Member

UCCX Version?How does your

UCCX Version?

How does your Create XML Doc step looks like?
And how does the vaule of the doc variable you use for this looks like?

Kartik

New Member

UCCX 9.0Document (DOC2)

UCCX 9.0

Document (DOC2) attached is what the create XML step looks like.

The document XML.doc is the document created from that step.

 

 

 
 

 

Please paste your screenshots

Please paste your screenshots in MS Paint and then save as PNG for uploading to the forums.  It's nicer than having the need to have MS Office installed.

The XML parser has some issues with name spaces in XML documents.  Prove that this is the case for you by hard coding your XML document as:

Set my_xml_doc = TEXT[<storeInfo><storeID>123</storeID><storeType>Main</storeType></storeInfo>]

Then pass that through your Create XML Document step as the source document and the output document.  It should change slightly to have an XML declaration added to the header.  That's expected.

Now, in your Get XML Document Data step use the following XPATH: "//storeID"

Hope that helps.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

It is a problem with the XML

It is a problem with the XML parser and name spaces, the above test proved that. How can I get around this issue. The XML document is created via a URL call to a web server. The docuement changes depending on the value sent to the web server and the information returned.

I'm not sure.  I have not run

I'm not sure.  I have not run into this more than once a few years ago.

But here's two suggestions:

1. Try running the String method .replace() on the String before converting it to a document.  This is a cheap way to remove text you don't want in the XML.

2. Our very own Contact Center VIP Gergely has posted some great documents, one of which shows him working with XML documents which contain name spaces.  It's likely a bit more complicated than what you have now though, so choose wisely.

https://supportforums.cisco.com/document/97736/uccx-8x-really-simple-soap-client-no-custom-jar

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

You are correct...Cisco's XML

You are correct...Cisco's XML parser (I believe its SAXv1..which some of its "parts" are deprecated by SAXv2) does not handle namespaces and other artifacts inside XML very well. And yes Greg is the man..I am Sam though..and I will be your man today and keep it really simple..but first you are going to have to Open a Curly Brace for me.

Go ahead and continue to use the Create XML Document Step..but instead of using the Get XML Data grab a Do Step and paste the code that I have here including the { } then apply and run the code...(ensuring the name of the String(s) I have defined here are the same as what you have..So..I am still getting used to the new styles in this forum..so I'm going to show a screenshot of what the code looks like and I'll attach a text file of code you can copy and paste..Just FYI, I updated the TXT File to Include TRY/CATCH block..because some of the activity going on in this code can Throw Exceptions (crash your program)...Not Captured in this Screenshot..

New Member

Hello SamThank you very much.

Hello Sam

Thank you very much. When I enter the above code into the DO step it throws an error "Unable to parse expression; invalid identifier: doc (line:1, col:309)

 

this the the statement at that point Doc=builder.parse(doc);

Right..pass in your defined

Right..pass in your defined Document name:

org.w3c.dom.Document domDoc = builder.parse(soapResponseDoc)

Ensure those String names match up as well with what you have defined and change them accordingly:

storeId

storeType

New Member

I thank you for your

I thank you for your assistance. This is returning the words "storeType/text()" in the script varible, instead of the value contained with in the document. I will play with this a bit and see if I can get it to return the values in the two namespaces.

So you are getting the value

So you are getting the value of storeId? If so then, I can see you are using the image file..which I did leave off the method that returns the value for that String:

storeType = xpath.evaluate(storeType, domDoc);

Edit:

I did attach a text file to the first message, so if you can use the code there (change Variable names as needed such as the Document you had issues with before) I included a TRY/CATCH block in the code just in case an Exception is thrown; if one does occur your application will crash and the caller will hear the "default" script message

New Member

Getting no value, the string

Getting no value, the string "storeType/text()" is returned to the script varible storeType. What I am trying to achieve (from the above example) 424 returned for storeID and Main returned for the storeType, and store them in the corrasponding script varibles. I did use the text file not the image which has the storeID xpath eval but not the storetype xpath eval.

Just as a side note, the storeID=xpath.evaluate(storeID, domDoc) returned the string "storeType/text()" in the storeType script varible. I thought this very strange.

Can you repost the entire XML

Edit: Try the Follow where I told you previously (soapResponseDoc); The resulting Document in your Create XML Document Step is the one listed below:

org.w3c.dom.Document domDoc = builder.parse(SOAPResponseXML)

Can you repost the entire XML Document? The one you previously posted was not a wellformed XML Document:

<?xml version="1.0"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"><?xml version="1.0" encoding="UTF-8"?>

 

Adding another screenshot of a snippet of how I'm interpreting what you are doing with debug and return values of code:

New Member

The document I have in the

The document I have in the org.w3c.dom.Document domDoc = builder.parse() is the SOAPResponseXML, so we should be good there. Attached is a screen shot of the script and the soapresponse.txt is the xml document produced by the create XML docuement step, I changed to .txt to upload.

Besides the copy into the

Besides the copy into the text file completely obliterating that XML Document..as I noticed from the DOCX that is not a wellformed XML Document. No Parser will analyze that and I'm surprised it actually makes it through the create XML Document Step..

A few more questions:When you

A few more questions:

When you debug your script and you get to the Create URL Document Step what is the result/value of soapResponseDoc? When you create the SOAPResponseXML Doc from the Create XML Document Step what is the result? If you are really doing SOAP..you can't do SOAP Requests with the builtin in Create URL Document Step. Interestingly, like Anthony said before me, I did take the "XML" you provided and ran it through a very dirty process that I would never recommend..but thought was interesting..

After you Create URL Document Step do the following:

Create a String called file and do the following:

Set file = soapResponseDoc

Grab a Do Step:

Do {

//Find the end of the "Root" Element with NS

int index = file.indexOf(">");

//"Remove" First Line in the File all the way thru \t\n

file = file.substring(index+3);

//Remove the "Root" Node Exit

file = file.replace("</string>", "");

soapResponseDoc = TEXT[file];

}

Now you will have a WellFormed XML File...Not knowing anymore details other than what you've provided to me..I would investigate either why you are getting "dirty xml" or take Anthony's inital response..make your SOAP Request Document..if you can provide the WSDL file and Parameters I need to send in the Request Document I could put something together for you if need be..

Attached is an image..the doc = URL syntax is the same as the Create URL Document Step you used in your procedure..

 

New Member

The results from the Create

The results from the Create URL is an HTTP Get. Just a bit of background, the original script was doing a SOAP call to a database. After more requirements and investigation, a middleware app was written to perform the SOAP call to the database and accept the HTTP request from UCCX and return the information.

So the varible names were not change to protect the innocence, that is why soap is in the names.

I will post the results of the above and answers to the other question tomorrow when I have access to the newtork.

Thank again.

New Member

URL[http://IPAddress

URL[http://IPAddress/StoreService.svc/LookupByAni?ani=555-555-1234]

This what is created by the URL docuement step. The ip address is the ip address of the middleware app and the 555-555-1234 is the phone number the ANI of the caller

This is the results from teh create XML document which uses the response from the Create URL document.

TEXT[<?xml version=\"1.0\" encoding=\"UTF-8\"?><string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;&lt;storeInfo&gt;&lt;storeID&gt;425&lt;/storeID&gt;&lt;storeType&gt;Main&lt;/storeType&gt;&lt;/storeInfo&gt;</string>]

 

That is NOT an XML Document

That is NOT an XML Document in the sense that it is not "WellFormed" ; there are 2 instances where xml version display..the one that follows the root element  breaks the format.

You really should get with your web team to get that cleaned up. In the meantime, you could try my cleanup method from above..but I probably should have just left that off..because this is no way to treat your application..

618
Views
15
Helpful
18
Replies
CreatePlease to create content