Highlighted
Trusted Contributor.
Trusted Contributor.
551 views

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?

 

 

Tags (1)
0 Likes
4 Replies
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

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
Click the Like button at the bottom to say 'Thanks'.
0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

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.

 

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

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.

 

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

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()
   

 

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.