How can z/OS call a web service?

12,769

Solution 1

Use the IBM TCP/IP 'EZASOKET' modules

I work for a company with a z/OS system running mostly COBOL, batch (JCL) and CICS. To call webservices, we wrote a module to implement HTTP 1.0 using TCP/IP. With modules

  • EZASOKET
    • GETHOSTBYNAME
    • SOCKET
    • CONNECT
    • WRITE
    • FCNTL
    • READ
    • CLOSE
    • SELECTEX

supplementary modules:

  • EZACIC04 translates EBCDIC to ASCII
  • EZACIC05 translates ASCII to EBCDIC
  • EZACIC06 convert character to bit mask
  • EZACIC08 decode IP address

Since I wrote this for my company, I can't just give out the code. But for reference, it took me 3 days to write the module, and that was with an example to start with that did a partial hacky way of doing it.

You'll need to read through IBM's references to know how to use the EZA modules.

Solution 2

It is possible to call java from COBOL programs on z/os.
We have done it in our company.

  1. You have to specify that it is RECURSIVE
  2. You have to import the classes

Class HelloJ is
"com.ibm.zos.batch.container.test.HelloJ"
Class JavaException is "java.lang.Exception"
Class BCDTranHelper is
"com.ibm.batch.spi.UserControlledTransactionHelper".

  1. The you have to include JNI. LINKAGE SECTION. COPY JNI

***Then you can invoke java from COBOL in your PROCEDURE DIVISION with:
Invoke HelloJ "sayHello"

Also look at Java Exception Check * to see how to handle the exceptions.

This is very useful if you want to invoke a web service from your COBOL program on z/os.

see this link for more details.

http://pic.dhe.ibm.com/infocenter/zos/v1r13/index.jsp?topic=%2Fcom.ibm.zos.r13.iean500%2Fcodeexm.htm

Share:
12,769

Related videos on Youtube

Tony Borf
Author by

Tony Borf

Updated on June 04, 2022

Comments

  • Tony Borf
    Tony Borf almost 2 years

    I have a COBOL program that needs to get data from a web service. Without using CICS what are my best options? I thought that a C program could read the web service and save it to a file, then the COBOL could read that file. Can COBOL call a web service? The data is about 300mb in size.