The Web application called for each request from the WWW Browser. ISAPI Subroutines can only call a program with this entry name. A program with this entry name must always be created.
The following explains the precautions to be taken when creating a program with this entry name.
IDENTIFICATION DIVISION
Write the program name in the PROGRAM-ID paragraph as shown below:
PROGRAM-ID. "HttpExtensionProc".
Note
Write the program name correctly, paying attention to the upper-case/lower-case characters. It is case sensitive when working with ISAPI. If the program name is not correct, the application will not run.
ENVIRONMENT DIVISION
None
DATA DIVISION
WORKING-STORAGE SECTION
Include the library file to be used to interface with ISAPI Subroutines using the COPY statement as follows:
WORKING-STORAGE SECTION. COPY COBW3.
This library file (COBW3.cbl) is stored in the folder in which COBOL is installed.
LINKAGE SECTION
Include the library file to be used to interface with IIS using the COPY statement as follows:
LINKAGE SECTION. COPY ISAPICTX.
This library file (ISAPICTX.cbl) is stored in the folder in which COBOL is installed.
PROCEDURE DIVISION
Write the following to fit to the calling interface from IIS.
PROCEDURE DIVISION WITH STDCALL LINKAGE USING ISAPI-CTX-CNT.
Since ISAPI-CTX-CNT obtained in the above way is needed for ISAPI Subroutines to exchange data with IIS, set its pointer to COBW3-CONTEXT as shown below:
MOVE LOW-VALUE TO COBW3. MOVE FUNCTION ADDR(ISAPI-CTX-CNT) TO COBW3-CONTEXT.
Return code
A return code to IIS when this function is completed needs to be set. The following two return code values are available, and "Normal end" is usually set. If "Abnormal end" is set, the WWW Server assumes that an error occurred in the relevant application and a message to that effect is sent to the WWW Browser by IIS.
Return code | Meaning |
1 | Normal end |
4 | Abnormal end |
To set "Normal end", for example, enter as follows:
MOVE 1 TO PROGRAM-STATUS. EXIT PROGRAM.
On the basis of the above, the sample of this program will look like the following:
IDENTIFICATION DIVISION. PROGRAM-ID. "HttpExtensionProc". ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. COPY COBW3. LINKAGE SECTION. COPY ISAPICTX. PROCEDURE DIVISION WITH STDCALL LINKAGE USING ISAPI-CTX-CNT. * MOVE LOW-VALUE TO COBW3. MOVE FUNCTION ADDR(ISAPI-CTX-CNT) TO COBW3-CONTEXT. * * Write processing as required. * MOVE 1 TO PROGRAM-STATUS. EXIT PROGRAM.