Skip to Content

What is the best way to retrieve XML via HTTP?

Estimated Reading Time: 1 Minutes

Question:

Suppose I want to retrieve XML with an HTTP request given a particular URL.
What is the easiest or best way to do this? Please provide a sample program.

Answer:

One way to communicate with an HTTP server is by using the HTTPClient class.
You can retrieve XML data in an XML envelope using HTTPClient methods, such as doGet.
There are several examples of using HTTPClient in %ISCOBOL%/samples, including the issamples/SAMPLES.cbl program (in the objects tab), and the samples in eis/webservice/soap/client and eis/http/xml.

There are other ways to get XML data from a URL.
isCOBOL includes an internal object named com.iscobol.rts.XMLStream.
We also support ACUCOBOL-GT's C$XML.
Because isCOBOL compiles to Java code, you can use Java language XML APIs and tools available to the Java programmer.
See the KB article "Does isCOBOL Support C$XML or other XML interfaces?".

isCOBOL also supports procedure division statements XML PARSE and XML Generate.
See the KB Article "What are all of the options for a COBOL program to read and write XML files?"

What is the best way to retrieve XML via HTTP?