TW_Mn
TW_Mn

Reputation: 13

AcuCobol external call

I'm trying to integrate some functionality from my company's old system to our new one.

We have some COBOL code running on ACUCOBOL v6.2 . Is there a simple way of making an external http call / or even a non-http call without purchasing AcuToWeb or another software bundle.

Upvotes: 1

Views: 1056

Answers (3)

Ian Harper
Ian Harper

Reputation: 11

The runtime has a utility called "rmnet" built in which can be used with options to do calls to a webserver using http.

See documentation for RMNet Routines.

RMNet Application Programming Interface (API) to emulate a browser that extracts information from a web site or interacts with a web service using SOAP.

RMNet moves data between the a web client, which is typically an ACUCOBOL_GT extend program, and a web server. A Universal Resource Locator (URL) describes the resource. The resource dictates the data format. For example, if submitting data to a web form used by a browser, the data must be formatted to comply with the W3C specification for application/x-www-form-urlencoded. When interacting with a SOAP web service, XML documents are exchanged.

There are samples in the runtime folder under samples have a look for the rmnet folder.

Upvotes: 0

frank
frank

Reputation: 1027

You can use C$SOCKET to establish a socket connection to a server on port 80.
Then you can send a http request, an read the answer.

78  NL          value X"0A".

...

call "C$SOCKET" using AGS-CREATE-CLIENT,
        port, host giving socket-handle

...

move spaces     to zw-get
move 1      to zw-length
string "GET "               delimited by size
        "YourPath"          delimited by size
        " HTTP/1.1"         delimited by size
        NL                  delimited by size
        "HOST: "            delimited by size
        "YourHost"          delimited by size
        NL                  delimited by size
        NL                  delimited by size
    into zw-get
    with pointer zw-length
end-string
subtract 1      from zw-length 

call "C$SOCKET" using AGS-WRITE,
        socket-handle, zw-get, zw-length

...

initialize zw-length zw-answer
call "C$SOCKET" using AGS-READ,
    socket-handle, zw-answer, zw-length, READ-TIMEOUT

Upvotes: 1

Scott Nelson
Scott Nelson

Reputation: 616

I can think of a few ways to handle this:

  1. Call an external (non-cobol) program via opening a "file" with the file name beginning with "-P". This makes acucobol create a pipe to the program. You can either read or write to the external program but not both. I typically use command line arguments or a regular file for the other side of the conversation, but you can't easily have both open at the same time. For example, open -Pcurl https://www.google.com/?q=acucobol for input, or -Pps2pdf > /tmp/pdf-file as output and send it some postscript.
  2. Call an external program via CALL "SYSTEM" USING COMMAND-LINE
  3. Create a C subroutine that will interface with the external system, and use AcuCOBOL's methods of linking with C programs.

Upvotes: 1

Related Questions