All Downloads are FREE. Search and download functionalities are using the official Maven repository.

vlc.c2j-operation-cobol-cics-lshttapi-client.vm Maven / Gradle / Ivy

Go to download

Generates adapters and proxies for inbound and outbound mainframe integration with Web Services.

There is a newer version: 1.5.3
Show newest version
       PROCESS XOPTS(APOST)
       PROCESS NOSEQ LIB OPTIMIZE(FULL)
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ${cixsOperation.cicsProgramName}.
      *****************************************************************
      * OVERVIEW                                                      *
      * --------                                                      *
      * Sample transaction calling a remote service using LegStar     *
      * HTTP client C API (LSHTTAPI).                                 *
      * The HTTP body contains a formatted LegStarMessage.            *
      * It is expected that the receiver will use LegStar COBOL       *
      * binding to convert payload to a Java object.                  *
      *                                                               *
      * Program generated by ${generatorName}.    *
      * Follow the TODO markers to customize this program.            *
      *****************************************************************

       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       DATA DIVISION.
      *****************************************************************
      *        W O R K I N G    S T O R A G E    S E C T I O N        *
      *****************************************************************
       WORKING-STORAGE SECTION.
       
      *---------------------------------------------------------------*
      *  Constants                                                    *
      *---------------------------------------------------------------*
      * Address of service provider.
      *    
${structHelper.getAlphanumDataItemCode(77, "W00-SERVICE-URI", ${httpURL.length()}, "${httpURL}")}
      *    
      * Service credentials.
      *    
#if(${httpUserId.length()} == 0)
       77  W00-USERID                    PIC X(8) VALUE SPACES.
#else
${structHelper.getAlphanumDataItemCode(77, "W00-USERID", ${httpUserId.length()}, "${httpUserId}")}
#end
#if(${httpPassword.length()} == 0)
       77  W00-PASSWORD                  PIC X(8) VALUE SPACES.
#else
${structHelper.getAlphanumDataItemCode(77, "W00-PASSWORD", ${httpPassword.length()}, "${httpPassword}")}
#end
      *    
      * Service requested.
      *    
${structHelper.getAlphanumDataItemCode(77, "W00-SERVICE-NAME", ${model.name.length()}, "${model.name}")}
           
      *---------------------------------------------------------------*
      *  CICS API parameters                                          *
      *---------------------------------------------------------------*
       01  W03-RESP                      PIC S9(9) BINARY VALUE 0.
           88  OK-CODE            VALUE 0.
           88  ERROR-CODE         VALUE -1.
       01  W03-RESP2                     PIC S9(9) BINARY VALUE 0.

      *---------------------------------------------------------------*
      * LSHTTAPI API parameters                                       *
      * C Structures are aligned on natural storage boundaries so we  *
      * need to specify SYNCHRONIZED.                                 *
      * The last character of each string is reserved to hold a       *
      * C string delimiter.                                           *
      *---------------------------------------------------------------*
       01  LAPI-TRACE-PARMS SYNCHRONIZED.
           05 LAPI-TRACE-ID              PIC X(17) VALUE SPACES.
           05 LAPI-TRACE-MODE            PIC S9(8) BINARY VALUE 1.
              88 TRACES-OFF       VALUE 0.
              88 TRACES-ON        VALUE 1.
           05 LAPI-ERROR-MESSAGE         PIC X(266) VALUE SPACES.

       01  LAPI-INVOKE-PARMS SYNCHRONIZED.
           05  LAPI-URI                  PIC X(513) VALUE SPACES.
           05  LAPI-SERVICE-NAME         PIC X(33) VALUE SPACES.
           05  LAPI-REQUEST-DATA         POINTER VALUE NULL.
           05  LAPI-REQUEST-DATA-LEN     PIC S9(8) BINARY VALUE ZERO.
           05  LAPI-REPLY-DATA           POINTER VALUE NULL.
           05  LAPI-REPLY-DATA-LEN       PIC S9(8) BINARY VALUE ZERO.
           05  LAPI-OPTIONS.
               10  LAPI-CONNECT-TIMEOUT  PIC 9(9) BINARY VALUE 3.
               10  LAPI-RECV-TIMEOUT     PIC 9(9) BINARY VALUE 10.
               10  LAPI-PROXY-URI        PIC X(513) VALUE SPACES.
               10  LAPI-USERID           PIC X(33) VALUE SPACES.
               10  LAPI-PASSWORD         PIC X(33) VALUE SPACES.
           
      *---------------------------------------------------------------*
      *  Work variables                                               *
      *---------------------------------------------------------------*
       01  ERROR-MESSAGE          PIC X(78) VALUE SPACES.
           88 NO-ERROR-MESSAGE VALUE SPACES.

      *---------------------------------------------------------------*
      *  Request parameters expected by target web service            *
      *---------------------------------------------------------------*
       01 COM-REQUEST.
${structHelper.getInputStructuresCode($cixsOperation, 2, 1)}
       
      *****************************************************************
      *            L I N K A G E       S E C T I O N                  *
      *****************************************************************
       LINKAGE SECTION.

      *---------------------------------------------------------------*
      *  Reply parameters as returned by target web service           *
      *---------------------------------------------------------------*
       01 COM-REPLY.
${structHelper.getOutputStructuresCode($cixsOperation, 2, 1)}
               
      *****************************************************************
      *    P R O C E D U R E  D I V I S I O N   S E C T I O N         *
      *****************************************************************
       PROCEDURE DIVISION.

           PERFORM PROLOG THRU
               END-PROLOG.

           PERFORM INVOKE-SERVICE THRU
               END-INVOKE-SERVICE.
               
           PERFORM EPILOG THRU
               END-EPILOG.

           GOBACK.
       
      *---------------------------------------------------------------*
      *  Initialize the c2ws API. You can turn traces on and specify  *
      *  a trace identifier.                                          *
      *---------------------------------------------------------------*
       PROLOG.

           DISPLAY
               '${cixsOperation.cicsProgramName} STARTING ==============================='. 
      *
      * Initialize c2ws API passing trace parameters
      *    
           MOVE '${cixsOperation.cicsProgramName}' TO LAPI-TRACE-ID.
           
           CALL 'init' USING dfheiblk LAPI-TRACE-PARMS
                       RETURNING W03-RESP.
           IF (NOT OK-CODE)
               MOVE 'INITIALIZE-LSHTTAPI failed' TO ERROR-MESSAGE
               PERFORM ABORT-PROGRAM THRU
                   END-ABORT-PROGRAM
           END-IF.

      *
      * Setup invoke parameters
      *    
           MOVE W00-SERVICE-URI   TO LAPI-URI.
           MOVE W00-USERID        TO LAPI-USERID.
           MOVE W00-PASSWORD      TO LAPI-PASSWORD.
           MOVE W00-SERVICE-NAME  TO LAPI-SERVICE-NAME.

           PERFORM SET-REQUEST THRU
               END-SET-REQUEST.

           SET LAPI-REQUEST-DATA     TO ADDRESS OF COM-REQUEST.
           MOVE LENGTH OF COM-REQUEST TO LAPI-REQUEST-DATA-LEN.
           
           DISPLAY 'PROLOG ENDED'.
           
       END-PROLOG.   EXIT.
      
      *---------------------------------------------------------------*
      *  Populate the request parameters                              *
      *---------------------------------------------------------------*
       SET-REQUEST.

           DISPLAY 'SET-REQUEST STARTED'.

      *  TODO set input values in COM-REQUEST                         *
           
           DISPLAY 'SET-REQUEST ENDED'.

       END-SET-REQUEST.   EXIT.
       
      *---------------------------------------------------------------*
      *  Invoke target service and analyze response                   *
      *---------------------------------------------------------------*
       INVOKE-SERVICE.

           DISPLAY 'ABOUT TO INVOKE-SERVICE'.
      *
      * Invoke target web service
      *    
           CALL 'invoke' USING LAPI-INVOKE-PARMS
                         RETURNING W03-RESP.
           IF (NOT OK-CODE)
               MOVE LAPI-ERROR-MESSAGE TO ERROR-MESSAGE
               PERFORM ABORT-PROGRAM THRU
                   END-ABORT-PROGRAM
           END-IF.
           
           SET ADDRESS OF COM-REPLY TO LAPI-REPLY-DATA.

           PERFORM PRINT-RESULTS THRU
               END-PRINT-RESULTS.

           DISPLAY 'INVOKE-SERVICE SUCCESS'.
           
       END-INVOKE-SERVICE.   EXIT.
      
      *---------------------------------------------------------------*
      *  Display results returned from target web service             *
      *---------------------------------------------------------------*
       PRINT-RESULTS.
       
      *  TODO do something useful with data returned in  COM-REPLY    *
           
       END-PRINT-RESULTS.   EXIT.
       
      *---------------------------------------------------------------*
      *  Terminate program.                                           *
      *---------------------------------------------------------------*
       EPILOG.

           PERFORM EXIT-PROGRAM THRU
               END-EXIT-PROGRAM.
           
       END-EPILOG.   EXIT.

      *---------------------------------------------------------------*
      *  Free keyboard and return to CICS                             *
      *---------------------------------------------------------------*
       EXIT-PROGRAM.
       
           EXEC CICS SEND CONTROL FREEKB END-EXEC.
           
           DISPLAY '${cixsOperation.cicsProgramName} STOPPING ==============================='.
           EXEC CICS RETURN END-EXEC.

       END-EXIT-PROGRAM.   EXIT.

      *---------------------------------------------------------------*
      *  Something went wrong. Report error and exit.                 *
      *---------------------------------------------------------------*
       ABORT-PROGRAM.
           
           PERFORM DISPLAY-ERROR-MESSAGE THRU
               END-DISPLAY-ERROR-MESSAGE.
               
           PERFORM EXIT-PROGRAM THRU
               END-EXIT-PROGRAM.

       END-ABORT-PROGRAM.   EXIT.

      *---------------------------------------------------------------*
      *  Display error messages                                       *
      *---------------------------------------------------------------*
       DISPLAY-ERROR-MESSAGE.

           EXEC CICS SEND TEXT FROM(ERROR-MESSAGE) FREEKB END-EXEC. 
           DISPLAY '************************************************'.
           DISPLAY '* ', ERROR-MESSAGE.
           DISPLAY '* COMPLETION CODE : ', W03-RESP.
           DISPLAY '* REASON CODE     : ', W03-RESP2.
           DISPLAY '************************************************'.

       END-DISPLAY-ERROR-MESSAGE.   EXIT.

       END PROGRAM ${cixsOperation.cicsProgramName}.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy