IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

PL/1 Callback address logic in z/OS CWE toolkit


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nav_kat24

New User


Joined: 10 Feb 2022
Posts: 2
Location: Europe

PostPosted: Thu Feb 10, 2022 11:27 am
Reply with quote

Hello dear mainframe experts !!

I'm going thru SYS1.SAMPLIB(HWTHPXPI1) program to understand z/OS CWET. I have already compiled the program and executed the logic and its successful.

However, I stumbled up on callback logic which I never worked on and trying to understand how it works. I know that the address of HWTHHRX and HWTHBDYX are assigned and set before issuing HWTHRQST call.

So can any one please explain to me if HWTHHDRX and HWTHBDYX are external procs. Can they get compiled separately. ? How the logic works ?.

I have recently started working on PL/1 and my PL/1 knowledge is limited to my organisation MF site specific.


Code:
HWTHXPI1: PACKAGE EXPORTS(*);

 %INCLUDE SYSLIB(HWTHIPLI);  /* HTTP Interface Declaration File */

 HWTHXPI1:   PROCEDURE  OPTIONS( MAIN )
     Returns(Fixed Binary(31));

 Dcl CallbackAddr    Limited entry External;
 Dcl CallbackAddrPtr Ptr;

 CallbackAddr = HWTHHDRX;
 CallbackAddrPtr = Addr( CallbackAddr );
 Option = HWTH_OPT_RESPONSEHDR_EXIT;
 OptionValueLen  = 4;
 OptionValueAddr = CallbackAddrPtr;
 .
.
.
 Call HWTHSET( Rc,
               HandleIn,
               Option,
               OptionValueAddr,
               OptionValuelen,
               DiagArea );


.
.
.
.
 CallbackAddr = HWTHBDYX;
 CallbackAddrPtr = Addr(CallbackAddr);
 Option = HWTH_OPT_RESPONSEBODY_EXIT;
 OptionValueLen  = 4;
 OptionValueAddr = CallbackAddrPtr;

 Call HWTHSET( Rc,
               HandleIn,
               Option,
               OptionValueAddr,
               OptionValuelen,
               DiagArea );
.
.
.
 Call HWTHRQST( Rc,             
               ConnectHandle, 
               RequestHandle, 
               DiagArea );     
.
.
 End HWTHXPI1;





 HWTHHDRX: Procedure( HTTPResponseLine,
                      exitFlags,
                      namePtr,
                      nameLen,
                      valuePtr,
                      valueLen,
                      userDataPtr,
                      userDataLen )
           OPTIONS(REORDER)
           Returns(Fixed Binary(31) ByValue);
 
 Dcl HTTPResponseLine Type HWTH_STATUS_LINE_TYPE;
 Dcl exitFlags        Type HWTH_RESP_EXIT_FLAGS_TYPE;
 Dcl namePtr      Ptr;
 Dcl nameLen      Fixed Binary(32) Unsigned;
 Dcl valuePtr     Ptr;
 Dcl valueLen     Fixed Binary(32) Unsigned;
 Dcl userDataPtr  Ptr;
 Dcl userDataLen  Fixed Binary(32) Unsigned;

 Dcl ResponseVersion Char(32)
                     Based(HTTPResponseLine.HWTH_VersionPtr);
 Dcl ResponseReason  Char(32)
                     Based(HTTPResponseLine.HWTH_ReasonPtr);

 Dcl CONTENT_LENGTH_NAME  Char(14)  Value('CONTENT-LENGTH');
 Dcl HdrName     Char(14) Based(namePtr);
 Dcl HdrValue    Char(10) Based(valuePtr);
 Dcl UpperName   Char(14);
 Dcl Reason      Char(32);
 Dcl rsnLen      Fixed Binary(31);

 /************************************************************
  * Data area passed to this callback from the main program.
  ************************************************************/
 Dcl 1 HdrUserdata  Based( userDataPtr )
      ,3 * Char(8)
      ,3 HdrHttpStatusCodeAddr  Ptr
      ,3 HdrContentLengthAddr   Ptr
     ;

 Dcl HttpStatusCode Fixed Binary(32) Unsigned
                         Based(HdrUserdata.HdrHttpStatusCodeAddr);
 Dcl ContentLength  Char(10)
                         Based(HdrUserdata.HdrContentLengthAddr);

 /************************************************************
  * Display the status code and reason the first time this
  * header exit routine receives control, and save the status
  * code in the sharable place designated by the userdata
  ************************************************************/
 If HttpStatusCode = 0 Then
    Do;
    HttpStatusCode = HttpResponseLine.HWTH_statusCode;
    /***********************************************************
     * If the web server did not return the expected status,
     * indicate that the balance of response processing is to
     * be aborted (in which case HWTHRQST resumes control and
     * indicates this condition)
     **********************************************************/
    If HttpStatusCode ^= 200 Then
       Do;
       Display( 'Unexpected HTTP Status Code encountered' );
       Display( 'Expected: 200, Received: '||HttpStatusCode );
       Return (HWTH_RESP_EXIT_RC_ABORT);
       End;
    Else
       Do;
       Display( 'HTTP status: '||
                  Collapse( HttpResponseLine.HWTH_statusCode, ' ' ) );
       rsnLen = HttpResponseLine.HWTH_ReasonLen;
       Reason = ' ';
       Reason = Substr( ResponseReason, 1, RsnLen );
       Display( 'HTTP reason: '||Reason );
       End;
    End;

  /***********************************************************
   * If this is the Content-Length header, then we will save
   * its value in a sharable place so that the response body
   * exit can corroborate it.
   ***********************************************************/
 If nameLen = Size( HdrName ) Then
    Do;
    UpperName = Uppercase( HdrName );
    If UpperName = CONTENT_LENGTH_NAME Then
       Do;
       ContentLength = '';
       ContentLength = Substr( HdrValue, 1, valueLen );
       End;
    End;

 Return(HWTH_RESP_EXIT_RC_OK);

 End HWTHHDRX;





HWTHBDYX: PROCEDURE( HTTPResponseLine,
                      exitFlags,
                      bodyPtr,
                      bodySize,
                      userDataPtr,
                      userDataLen )
           OPTIONS(REORDER)
           Returns(Fixed Binary(31) ByValue);

 Dcl HTTPResponseLine  Type HWTH_STATUS_LINE_TYPE;
 Dcl exitFlags    Fixed Binary(32) Unsigned;
 Dcl bodyPtr      Ptr;
 Dcl bodySize     Fixed Binary(32) Unsigned;
 Dcl userDataPtr  Ptr;
 Dcl userDataLen  Fixed Binary(32) Unsigned;

 /************************************************************
  * Data area passed to this callback from the main program.
  ************************************************************/
 Dcl 1 BdyUserdata  Based(userDataPtr)
      ,3 *  Char(8)
      ,3 BdyContentLengthAddr  Ptr
      ;

 Dcl ContentLength  Char(10) Based(BdyUserdata.BdyContentLengthAddr);
 Dcl exSize   Fixed Binary(31);

 /*********************************************************
  * Compare the expected size (content-length value saved
  * earlier by the response headers exit) with the value
  * of bodySize.
  *********************************************************/
 exSize = Fixed( ContentLength );
 If exSize = bodySize Then
    Display('Response body contains '||Collapse(exSize,' ')||' bytes');
 Else
    Do;
    Display( 'Response data length mismatch.' );
    Display( 'Expected content length: '||ContentLength );
    Display( 'Response body size: '||bodySize );
    End;

 Return (HWTH_RESP_EXIT_RC_OK);

 End HWTHBDYX;



TIA,
Nav
Back to top
View user's profile Send private message
lchui

New User


Joined: 10 Jun 2020
Posts: 7
Location: Canada

PostPosted: Fri Feb 18, 2022 6:10 am
Reply with quote

I just did a google search on "IBM HWTHBDYX" and there is an example COBOL code that calls HWTHHDRX and HWTHBDYX with their full method bodies included . Don't know if that helps?

github.com/IBM/zOS-Client-Web-Enablement-Toolkit/blob/master/Example-Cobol-AirportService/HWTHXCB1.cbl
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
Search our Forums:

Back to Top