Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a Web Service from COBOL or CL

I'm using AS400 and I have been asked to call a web service from the green screen.

How can thisbe this achieved?

Any sample COBOL or CL code would be very helpful.

like image 345
Anton Baclao Avatar asked Dec 17 '12 21:12

Anton Baclao


1 Answers

I wrote some "middleware" in RPGLE to call a web service (SOAP) and process the XML data returned. Here's the process in a nutshell:

1) Open a socket to the web service
2) Build the XML "payload"
3) Transmit the SOAP request (wrap the payload in a SOAP body and transmit the whole through the socket opened in 1) and save the data sent back by the web service.
4) Parse the XML string returned to me (using the xml-sax BIF)
5) Process that data just like any other data.

I use a lot of stuff from Scott Klement (thank you very much Mr. Klement!):

ERRNO_H
IFS_H
IFSUTIL_H
SOCKET_H
SOCKUTIL_H

I also had to handle converting the data to/from EBCDIC and UTF-8. I think I modeled that process after something Scott wrote as well but I can't remember for sure. Search for iconv to get started on that.

like image 86
Benny Hill Avatar answered Oct 04 '22 05:10

Benny Hill