CICS to Proxy API LSHTTAPI

Overview:

This C/370 sub-program can be used to invoke a remote Web Service or POJO from a CICS program.

Provided that a LegStar Proxy has been installed in an HTTP server, the API uses HTTP connectivity to the proxy which will in turn call a target Web Service, POJO, etc....

The messaging protocol used between the API and the proxy is identical to the one used for inbound calls to CICS programs by csokrt or chttprt. This means that data flowing between CICS and the proxy is raw EBCDIC relieving CICS from code page conversions and XML processing.

The API itself uses an HTTP library, called LSHTTLIB, also written in C/370. LSHTTLIB is a simple HTTP 1.0 library with support for basic authentication whose focus is on performance rather than functionality. Please note that this library connects CICS programs to the proxies, not to the target web service or POJO.

LSHTTLIB uses CICS Sockets. Please refer to z/os Communication Server documentation on how to setup IP CICS Sockets in the target CICS region.

When writing your client program you will need data descriptions of the input and output structures produced by the target web service. The COBOL Structures Generator module generates such data descriptions.

Limitations:

- LSHTTAPI does not support HTTP 1.1.

- LSHTTAPI does not support SSL.

This program has been tested for:

- CICS TS 2.3 (6.3.0 Command language translator)

- C/370 for OS/390 V2 R10

How to use:

The first step is to create and deploy a proxy in an HTTP engine. The Mainframe Service Generator module helps you generate such a proxy.

Once LSHTTAPI and LSHTTLIB have been compiled in a library available to your CICS region in the RPL list, you might need to define LSHTTLIB using RDO (unless programs get autoinstalled).

Then you can write a client application using using LSHTTAPI.

There are 2 structures that form the parameters passed to the API. Because these structures are shared with a C/370 program, all fields must be synchronized on fullword boundaries and character fields must be null terminated. The API offers 2 methods (strC2Cob and strCob2C) to help with formatting.

The first structure is used for tracing and error reporting. It must be passed on the very first call to the init API method:

Field nameSizeDescription
TRACE-ID17inA correlation ID for end to end tracing
TRACE-MODE4in0= traces off, 1= traces on
ERROR-MESSAGE266outHuman readable error message

Init parameters

The second structure is passed on every call to the invoke API method:

Field nameSizeDescription
URI513inThe c2wsrt gateway locator
SERVICE-NAME33inLogical name of the target web service
REQUEST-DATA4inA pointer to the request host data
REQUEST-DATA-LEN4inlength (in bytes) of the request host data
REPLY-DATA4outA pointer to the reply host data
REPLY-DATA-LEN4outlength (in bytes) of the request host data
CONNECT-TIMEOUT4inMax wait time for a gateway connection (seconds)
RECV-TIMEOUT4inMax wait time for a reply (seconds)
PROXY-URI513inIf gateway is behind a proxy
USERID33inIf gateway requires authentication (basic)
PASSWORD33inIf gateway requires authentication (basic)

Invoke parameters

Any error will be signaled back with a negative return code. HTTP standard error codes such as 404 or 500 becomes -404 and -500. In addition to these standard error codes, you may also get:

  • ------+-------------------------------------------------------------------------+ | -1 | Host specified in gateway URI is unknown | *------+-------------------------------------------------------------------------+ | -2 | Socket creation failure. Is socket supported in this CICS region? | *------+-------------------------------------------------------------------------+ | -3 | The host specified in gateway URI rejected the connection attempt | *------+-------------------------------------------------------------------------+ | -4 | The host specified in gateway URI forcefully disconnected | *------+-------------------------------------------------------------------------+ | -5 | Error while trying to send data to the gateway | *------+-------------------------------------------------------------------------+ | -7 | Unexpected reply received from the gateway | *------+-------------------------------------------------------------------------+ | -9 | Data received from the gateway is not an HTTP header | *------+-------------------------------------------------------------------------+ | -10 | Out of memory error in the CICS region | *------+-------------------------------------------------------------------------+ | -11 | Error while trying to receive data from the gateway | *------+-------------------------------------------------------------------------+ | -12 | A URL does not start with the http scheme | *------+-------------------------------------------------------------------------+ | -13 | A URL specifies an invalid port number | *------+-------------------------------------------------------------------------+ | -14 | User/Password combination is too long | *------+-------------------------------------------------------------------------+ | -15 | An operation timed out | *------+-------------------------------------------------------------------------+

Error codes

You can activate trace mode by setting TRACE-MODE to 1. As a result details of the execution will be printed to the CICS CESO TD Queue which usually points to CEEOUT. Traces are correlated using the TRACE-ID.