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

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Create XML document hangs up after create url document

I am using a create url document step to access a database.  The url returns xml.  Then I use create xml document step followed by a get xml document data step in order to populate a variable based on the status indicated in the xml.  When I debug the script, it hangs up on the create xml document step.  I have included a partial sanitized script as I really do not have any idea where this is going wrong.  If I browse to the url, I get the xml I am looking for.

This is UCCX 9.0.2

As always, I appreciate the assistance.

1 ACCEPTED SOLUTION

Accepted Solutions

Create XML document hangs up after create url document

I'll do my best to point you in the right direction, but ultimately this how I make my living!

If you've seen the code, and there should be a few examples out there. You'll want to put the Java within a SET step enblocked such as this:

SET myXMLReturn = { /* java code here */ }

A couple notes:

  • You will need to use the full class names, i.e: java.net.InetAddress instead of InetAddress.
  • You'll need to read from the socket until EOF, something like a StringBuilder should make this easy.
  • Following that you need to "return myStringBuilderBuffer.toString();" in order for the data collected to be collected into myXMLReturn (which in this example would be a string.)

In addition, you really should be catching the relevant SocketExceptions including timeout. Speaking of timeout, you'll probably want to put one on your socket to prevent an indefinite hang and catch the exception it could throw. There's a fair amount of finessing involved so you dont end up throwing exceptions up to the Execution Context Engine (the Script) and crashing the script.

That should get you in ballpark, as it were.

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com
11 REPLIES

Create XML document hangs up after create url document

How quickly does the page respond when you manually access the URL? Also, how large is the returned XML file?

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com

Create XML document hangs up after create url document

I just noticed, you're making an HTTPS request. I don't believe this support was added with 9 - I may be wrong here.

If that is indeed the case, you will need to use some custom java to override the security manager to create an HttpsURLConnection to the server and return the data into your document or string variable then parse from there.

This is not overly complex.

Alternatively, if you can get away with HTTP to the server you'd be in a better position.

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com
New Member

Create XML document hangs up after create url document

Tanner,

First off please let me thank you for responding so quickly.  To answer both of your questions, it takes about 2 seconds when I just paste the real url into a browser to return the xml, I have set the timeout to as high as 10000 millilseconds.  Secondly, the xml response is simply two lines..the first line is the xml coding stuff and the second line is basically...

boolean/boolean

As for https, that is what the customer gave me, I do not have to enter a password in order to get the response, I can try http.  I can enter the https:// from any browser, would uccx handle that differently?

Create XML document hangs up after create url document

Mark,

It would, UCCX is simply using java underneath and java by default will not allow the creation of an HTTPSURLConnection to a server if the certificate is not within its' keystore. This is why overriding the security manager and connecting manually will overcome this issue (by effectively trusting any certificate provided).

If you are forced into using HTTPS this may be your only option.

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com
New Member

Create XML document hangs up after create url document

Tanner,

I did just try to connect to the url with http and I received the "this connection can only be viewed over a secure connection" message.

New Member

Create XML document hangs up after create url document

Tanner,

So how would I do that?  I am not anything close to a java programmer

Create XML document hangs up after create url document

How comfortable are you with Java?

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com
New Member

Create XML document hangs up after create url document

I can tell you that I have actually never even had a cup of coffee.  I know nothing about java.  I am looking it up and I do see code that does exactly what you are talking about but I have no idea about what any of it means or how I would implement it in a script.

Create XML document hangs up after create url document

I'll do my best to point you in the right direction, but ultimately this how I make my living!

If you've seen the code, and there should be a few examples out there. You'll want to put the Java within a SET step enblocked such as this:

SET myXMLReturn = { /* java code here */ }

A couple notes:

  • You will need to use the full class names, i.e: java.net.InetAddress instead of InetAddress.
  • You'll need to read from the socket until EOF, something like a StringBuilder should make this easy.
  • Following that you need to "return myStringBuilderBuffer.toString();" in order for the data collected to be collected into myXMLReturn (which in this example would be a string.)

In addition, you really should be catching the relevant SocketExceptions including timeout. Speaking of timeout, you'll probably want to put one on your socket to prevent an indefinite hang and catch the exception it could throw. There's a fair amount of finessing involved so you dont end up throwing exceptions up to the Execution Context Engine (the Script) and crashing the script.

That should get you in ballpark, as it were.

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com
New Member

Create XML document hangs up after create url document

Tanner,

Thanks for that and I do understand that you do not want to give away what you get paid for, I completely understand that.  This has turned out to be a non issue as my customer was only using https because the were previously using a hosted phone system so all their calls went through the Internet and now that they will be premise based, they are setting up url's that will listen on port 80 for me.

I really appreciate the information though.

Create XML document hangs up after create url document

Mark,

I'm glad to hear it. Where possible it is best to be able to avoid using those kinds of work arounds, particularly if you're not 100% comfortable with it. Ultimately while the Java would work, it becomes a support and maintaince issue and you'll probably just confuse the hell out of the next guy that has to work on it!

Regards,

Tanner Ezell
www.ctilogic.com

Tanner Ezell www.ctilogic.com
266
Views
0
Helpful
11
Replies