HTML
Quick Page Table of Contents
Scanning…
XMLSERVICE XMLCGI.PGM
This page is for IBM i developers that want to try XMLSERVICE using only HTML/XML (no scripting language).
{Download Demo (right one 2015-Jan-15)}
The sample program xmlservice/xmlcgi is an RPG program that supports HTTP GET/POST interface.
This is an easy interface to call XMLSRVICE during testing without the bother of writing a script.
← click to run demo
REST parameters (xmlcgi.pgm):
- db2 - what database (*LOCAL tested)
- uid - user profile (*NONE - no uid version 1.5+)
- pwd - profile password (*NONE - no password version 1.5+)
- ipc - IPC key name/security route to XMLSERVICE job (/tmp/fred01, etc.)
- ctl - CTL admin control XMLSERVICE job (see control below)
- xmlin - XML input document (request)
- xmlout - expected size of XML output document (response size in bytes)
Note: *NONE requires a special compile of the RPG source and is NOT enabled in production versions of the toolkit by default. It is most useful for demos with custom security like this site.
Step 1) Install XMLSERVICE
Download: 1) XMLSERVICE main page has download "latest". Install (see installation link above)
Step 2) Configure Apache
The RPG CGI sample module is included in the XMLSERVICE download.
Apache rest configuration (CGI interface) Example: Add the following to /www/zendsvr/conf/httpd.conf ScriptAlias /cgi-bin/ /QSYS.LIB/XMLSERVICE.LIB/ <Directory /QSYS.LIB/XMLSERVICE.LIB/> AllowOverride None order allow,deny allow from all SetHandler cgi-script Options +ExecCGI </Directory> Optional for server side includes (very handy for pure html/xml sites): # server side includes # AddOutputFilter INCLUDES .htm # AddOutputFilter INCLUDES .html Options +ExecCGI +Includes AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddOutputFilter INCLUDES .html
IMPORTANT: If you are running a machine with CCSID 65535 (and nothing works), please read and follow the documentation (main XMLSERVICE page), setting valid CCSID like 37 for Apache (web) and/or command line PHP (pear tests).
/www/zendsvr/conf/httpd.conf (web admin GUI port 2001 - ZENDSVR): DefaultFsCCSID 37 ... or 280 (Italian) ... or so on ... CGIJobCCSID 37 ... or 280 (Italian) ... or so on ...
Step 3) Example - Use HTML/XML to make the call
Here is a simple HTML form that asks for your user id and password and will run your script.
<form name="input" action="http://MYIBMIMACHINE/cgi-bin/xmlcgi.pgm" method="post"> <input type="hidden" name="db2" value="*LOCAL"> <input type="text" name="uid" value="MYUSERID"> <input type="password" name="pwd" value="MYPASSWORD"> <input type="hidden" name="ipc" value="/tmp/MYUSERID0001"> <input type="hidden" name="ctl" value="*sbmjob"> <input type="hidden" name="xmlin" value="<?xml version='1.0'?> <script> <comment>your XML script here, cmd, sh, sql, pgm (below)</comment> </script>"> <input type="hidden" name="xmlout" value="500000"> <input type="submit" value="MYBUTTON" /> </form>
Examples (from demo):
- index.html - HTML XML scripts (multiple <sql></sql> not required to run DB2, but it made XSLT easier).
- DemoXlst.xsl - XSLT (styles), colors of XML are in here
- RPG tests called by demos (RPG crttest included with RPG xmlservice download main page)
- zzcall.rpgle - RPG PGM test
- zzsrv.rpgle - RPG SRVPGM test
The HTML/XML file should be included where your IBM i Apache can find web pages (based on httpd.cpnf).
/www/zendsvr/htdocs/index.html -- or -- /www/apachedft/htdocs/index.html -- or -- wherever you configured XMLCGI httpd.conf.
To run just point your browser at the page and/or point your REST capable client program at this location to get REST “web service” XML document.
http://myibmi/index.html Output: <?xml version='1.0'?> <pgm name='ZZCALL' lib='XMLSERVICE'> <parm><data>C</data></parm> <parm><data>D</data></parm> <parm><data>321.1234</data></parm> <parm><data>1234567890.12</data></parm> <parm> <ds> <data>E</data> <data>F</data> <data>333.3330</data> <data>4444444444.44</data> </ds> </parm> <return><data>0</data></return> </pgm>
Note: Some browsers do not display the returned XML formatted, so you may have to use the browser pull downs to see “page source” to see the returned XML. Personally, i just use XSLT or CSS to format the XML into something pretty to avoid the whole browser goop XML issue.
Step 4) Kill XMLSERVICE job
The keywords used to route the kill order are ctl=“*immed” and ipc=“/tmp/rangerhtml” (same ipc used above example).
<!-- XMLSERVICE end process (kill) --> <form name="input" action="/cgi-bin/xmlcgi.pgm" method="post"> <input type="hidden" name="db2" value="*LOCAL"> <input type="text" name="uid" value="MYUSERID"> <input type="password" name="pwd" value="MYPASSWORD"> <input type="hidden" name="ipc" value="/tmp/MYUSERID0001"> <input type="hidden" name="ctl" value="*immed"> <input type="hidden" name="xmlin" value="<?xml version='1.0'?> <?xml-stylesheet type='text/xsl' href='/wiki/uploads/XMLService/DemoXslt.xsl'?> <script> </script>"> <input type="hidden" name="xmlout" value="500000"> <input type="submit" value="*immed end (kill job)" /> </form>
Author(s)
Tony “Ranger” Cairns - IBM i PHP / PASE