AS/400 Reverse API Client Deployment
AS/400 Reverse API Client prerequisites
Installing Generated Clients
Prerequisites:
- iSeries 7.1 or newer (1).
- ILE C compiler.
- ILE COBOL compiler.
- HTTPApi (<https://www.scottklement.com/httpapi/>) is required
Follow the link above. Download and follow installation instructions - Compile and OLCBLAPIC.c as a service program - This will be a C interface between the COBOL client and HttpApi. This Class will be referenced by the clients we generate from CLI
CRTCMOD MODULE(<some Library>/OLCBLAPIC)
SRCSTMF('/<somePath>/OLCBLAPIC.c')
Integrating the Generated COBOL Client into Your Application
The generated COBOL client includes four essential components. Follow these steps to adapt and incorporate it into your program:
Key Components of the COBOL Client
-
Working Storage Section:
- HTTP-REQUEST: Contains the parameters for invoking the remote web service.
- HTTP-RESPONSE: Contains the response from the remote web service.
- WS-API-CALLER-VARS: Includes the following fields:
- WS-URL: The target remote web service URL, which may need updating with the correct endpoint.
- WS-API-KEY: A HUB-generated API key that may need updating. (TODO: Investigate how to generate this key).
- WS-RESULT: Holds the result of the API call, with possible response values.
-
Procedure Division:
- Use the
CALL
statement to invoke the C interface.
- Use the
Instructions for COBOL Developers
- Incorporate the Components: Add these sections to your COBOL program, or create a sub-program that can be called as needed.
- Program Creation: Create the program using the components as described.
Steps to Compile and Link the Program with Required Modules
-
Create the Module: Compile the COBOL program and create a module using
CRTCBLMOD
orCRTSQLCBLI
. -
Create the Program (PGM): Link the COBOL module with the C interface module. Use the following command, adjusting the parameters to match your libraries and program names:
CRTPGM PGM(<pgm-lib>/<pgm-name>) MODULE(<module-lib>/<module-name> <c-intf-lib>/OLCBLAPIC <other-modules>) BNDSRVPGM((<http-api-lib>/HTTPAPIR4 *IMMED))
- Parameters:
<pgm-lib>
: Target library for the program.<pgm-name>
: Name of the program.<module-lib>
: Library where the compiled module resides.<module-name>
: Name of the program’s module.<c-intf-lib>
: Library containing the COBOL/C interface module.<other-modules>
: Any additional modules required by your program.<http-api-lib>
: Location of the HTTPApi service module. Use*LIBL
if it is already in your library list.
- Parameters:
These steps will allow COBOL developers to effectively integrate the generated client into their application, ensuring compatibility with the remote web service and C interface.
Updated 4 months ago