UCMDB and UD Practitioners Forum (Previously CMS)
cancel

Reading xml stream

Highlighted
Everett Sumner
New Member.

Reading xml stream

We need to read an xml stream from a url.  Every example I've seen in the OOB adapters involves reading xml from a file.  What is the trick in reading from the output of a url?

 

 

4 REPLIES
Dima Gomel
HPE Expert

Re: Reading xml stream

In most cases "stream" of XML from URL have soem technology behind it. For instance Web Services is one of examples.

Check what your technology is; then check if there is OOTB package connecting using the technology. 

Use it as a template.

Hope this helps.

Regards
-Dmitry Gomel, PMP
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
Click the Like button at the bottom to say 'Thanks'.
Everett Sumner
New Member.

Re: Reading xml stream

This interface is to a home grown database.  They no longer want to grant access to the schema.  Instead, they wrote some code to expose the data in xml format by sending a url.  I've seen ways to parse xml, but it is from a file and that's not how we have to access it.

 

Everett Sumner
New Member.

Re: Reading xml stream

I think I found the solution in urllib.  It seems to let me read from a stream coming from a url just like from a file.

 

Everett Sumner
New Member.

Re: Reading xml stream

I couldn't get a connection using urllib2.  I kept getting a socket error and I couldn't track it down.

 

I finally was successful using HttpClient.  The url and cookie are parameters in the adapter.

 

from org.apache.commons.httpclient.methods import GetMethod, HeadMethod
from org.apache.commons.httpclient import HttpClient  

 ....

 

    client = HttpClient()
    method = GetMethod(DIPSUrl)         
    method.setRequestHeader("cookie","WSL-credential=" + WSLCookie)
    statusCode = client.executeMethod(method)   
    logger.debug("status code = " + str(statusCode))
    DIPSResponse = method.getResponseBodyAsString()
   

 

 

//Add this to "OnDomLoad" event