Skip to content

CMNURIRX (Easy access to http methods from a REXX exec)

This program is a wrapper to the same engine as driven by CMNURIBA (note: this is common module CMNURI00), it does the same things except in a more REXX exec 'friendly' fashion. Originally intended for execution from a ZMF HLL exit written in REXX, but it could be executed from any REXX exec.

Note that the default URN implemented by CMNURIRX is /<context>/event/hllx or /zmfevent/event/hllx if context is not specified, i.e. the REST server as used by HLL exits. The equivalent SYSIN and JSONIN parameters are passed to CMNURIRX via stem variables. Output from the program (like sysprint from the batch version) is also passed back via a stem variable. It's easiest to see how this works from an example. The following was implemented into an HLLX REXX exec:

...

/*  REXX  */ 
proceed = 'YES' 
inStem   = 'ZMFUriParm' 
outStem  = 'ZMFUriMsg' 
jsonStem = 'ZMFUriJson'    

Say '---------------------------------------------------------' 
Say 'HLL exit point FREZ00XM - prior to package freeze service' 
Say ' This exit is being called prior to the freeze of' 
Say ' package: 'packageId 
Say '---------------------------------------------------------' 
Say ' ' 

ZMFUriParm.0 = 4 
ZMFUriParm.1   = 'Server=d001.microfocus.com' 
ZMFUriParm.2   = 'Port=8085' 
ZMFUriParm.3   = 'Trace=NO' 
ZMFUriParm.4   = 'Method=POST' 
ZMFUriJson.0 = 4 
ZMFUriJson.1   = '{' 
ZMFUriJson.2   = '  "EVENT"    : "40",' 
ZMFUriJson.3   = '  "PACKAGE"  : "'packageId'" ' 
ZMFUriJson.4   = '}' 

Call SYSCALLS 'SIGOFF'

address LINKMVS 'CMNURIRX inStem outStem jsonStem' 

If RC = 0 then  
   Do
      Say 'Pre-freeze Jenkins pipeline has completed successfully'
   End 
Else  
   Do
      Say 'Pre-freeze Jenkins pipeline was unsuccessful, messages follow'    
      If ZMFUriMsg.0 <> 0 then
         Do i = 1 to ZMFUriMsg.0
            Say ZMFUriMsg.i
         End
      proceed  = "NO"    
      shortMsg = "Jenkins process failed"    
      longMsg  = "Failure of Jenkins pipeline has caused this freeze to fail."  
   End 
exit 0

Here we have three stem variables, zmfUriParm (for input parameters), zmfUriMsg (for output messages) and zmfUriJson (for input JSON body statements). The input stem variables are populated as if you were supplying sysin and JSON to the batch CMNURIBA utility. The output message stem variable is accessed as you would any stem variable and you can see it being 'SAY'ed in the above REXX.

The rootnames of these stem variables (i.e. without the ending period) are set in the three simple variables inStem, outStem, jsonStem and passed, in that order, as parameters to a LINKMVS call to CMNURIRX.