Are there are any samples of OPS/MVS REXX scripts that use "address USS WEBREQ"?
OPS/MVS 14.0 and newer
The below sample shows how to code for a USS WEBREQ query of the RDF Tables:
/*------------------------------------------------------------
* Sample to invoke OPS REST server via ADDRESS USS WEBREQ.
* The sample gets the list of defined RDF tables, and displays
* the results. Since the result is a complex JSON object,
* only the top-level items are parsed. However, the full body
* is displayed.
*
* Set appropriate values for each of the following variables.
* Do not embed any whitespace in the values, or OPS/Rexx
* will complain about syntax errors.
*
* Run via the OI or OX commands, in an OSF server or a
* normal TSO session.
*------------------------------------------------------------*/
OPSHOST = "hostname_or_ip_address"
OPSPORT = "numeric_port"
OPSPWD = "password"
OPSUSER = "userid"
OPSMETHOD= "GET"
EXPECTED = "200"
OPSURI = "/opsmvs/web/tables/"
/*------------------------------------------------------------
* Construct the WEBREQ command by stepwise appending the
* various keywords and the values provided above.
* For the example, no changes are needed below this point.
*------------------------------------------------------------*/
cmd = "WEBREQ"
cmd = cmd "host("OPSHOST")"
cmd = cmd "port("OPSPORT")"
cmd = cmd "uri('"OPSURI"')"
cmd = cmd "password("OPSPWD")"
cmd = cmd "user("OPSUSER")"
cmd = cmd "METHOD("OPSMETHOD")"
cmd = cmd "OPT(parseresp)"
/*------------------------------------------------------------
* Issue the request
*------------------------------------------------------------*/
address uss cmd
/*------------------------------------------------------------
* If the request had the expected result, display the * parsed output
*------------------------------------------------------------*/
if webreq.httpcode = EXPECTED then do
say "Parsed response:"
do I = 1 TO webreq.body.json.0
say " " webreq.body.json.name.i"="webreq.body.json.value.i
end
end
/*------------------------------------------------------------
* Otherwise, display all return codes and error messages
*------------------------------------------------------------*/
else do
say "Expected HTTPCODE" expected " but got"
say " OPS/REXXx return code:" rc
say " WEBREQ Return Code: " webreq.retcode
say " WEBREQ Reason Code: " webreq.rsncode
say " HTTPCODE: " webreq.httpcode
say " Error text: " webreq.errtext
end
if queued() > 0 then do
say "Queued Messages:"
do queued()
parse pull x
say " " x
end
end
/*------------------------------------------------------------
* If a response body was retuned, display the entire content.
* Note that length(WEBREQ.BOD.TEXT) is limited to 32k, so
* may be less the length of the actual response, which is
* returned in WEBREQ.BODY.LENGTH.
*------------------------------------------------------------*/
if webreq.body.text <> "WEBREQ.BODY.TEXT" then do
len = length(WEBREQ.BODY.TEXT)
pos = 1
say "WEBREQ.BODY.TEXT: Length=" len "of" WEBREQ.BODY.LENGTH,
"in the response"
do while pos < len
say " " substr(webreq.body.text,pos,80)
pos = pos + 80
end
end