-
HTTP und RPG
Hallo Klaus,
vielleicht hilft dies:
Installing and Running an ILE RPG CGI Example
This sample code is provided by IBM for illustrative purposes only. It has not been fully tested. It is provided as-is without any warranties of any kind, including but not limited to the implied warranties of merchantability and fitness for a particular purpose.
This program is a simple RPG program that demonstrates the HTTP server APIs for reading standard input, reading an environment variable and writing standard output. This is done using the HTTP Server APIs.
To install the example program, do the following:
Download the following files:
samplerpg.txt - contains the RPG source code.
samplerpg.html - contains the html code that makes the request for the CGI.
Use the following CL commands to create a directory structure:
mkdir dir('/qsys.lib/rpgdemo.lib')
mkdir dir('/qsys.lib/rpgdemo.lib/qcsrc.file')
mkdir dir('/rpgdemo')
mkdir dir('/rpgdemo/html')
Be aware the mkdir command will use hierarchical file authorities, unless you specify otherwise, for the *PUBLIC users. You may want to specifically add read and execute authorities for server user profiles QTMHHTTP and QTMHHTP1 to these new directories.
Use FTP to connect to your server.
Use the following FTP commands to copy the files to your server:
put samplerpg.html /rpgdemo/html/samplerpg.html
put samplerpg.txt /qsys.lib/rpgdemo.lib/qcsrc.file/samplerpg.mbr
Use the following CL commands to create the program (PGM) object called SAMPLERPG:
CRTRPGMOD MODULE(rpgdemo/samplerpg) SRCFILE(rpgdemo/qcsrc) SRCMBR(samplerpg) OUTPUT(*print)
CRTPGM PGM(rpgdemo/samplerpg) MODULE(rpgdemo/samplerpg) BNDSRVPGM(qtcp/qtmhcgi)
Use your browser to access the HTTP Server Configuration and Administration forms to create either an original server or an Apache server configuration. For example: http://yourservername:2001.
Original server configuration:
Use the HTTP Server Configuration and Administration forms or the WRKHTTPCFG CL command to create an original server configuration. This configuration file should contain directives for accessing the samplerpg program and html. When you are finished you should have something like this in your configuration file for CGI related directives:
Enable Get
Enable Post
Exec /cgi-bin/* /QSYS.LIB/RPGDEMO.LIB/*
Pass /html/* /rpgdemo/html/*
Apache server configuration:
Use the HTTP Server Configuration and Administration forms to create an Apache server configuration. This configuration file should contain directives for accessing the samplerpg program and html. Set the document root to the /rpgdemo/html directory. The Alias and Redirection form will allow you to configure the Alias and ScriptAlias directives below. As the Apache server is secure by default when created via the gui, you will need to add a directory for the QSYS library allowing access to the directory and allowing CGI script execution. Use the Context Management form to add the directory for the QSYS (RPGDEMO.LIB) library. When you are finished you should have something like this in your configuration file for CGI related directives:
DocumentRoot /rpgdemo/html/
Alias /html/ /rpgdemo/html/
ScriptAlias /cgi-bin/ /QSYS.LIB/RPGDEMO.LIB/
<Directory /rpgdemo/html/>
AllowOverride None
Options None
order allow,deny
allow from all
</Directory>
<Directory /QSYS.LIB/RPGDEMO.LIB/>
AllowOverride None
SetHandler cgi-script
Options +ExecCGI
order allow,deny
allow from all
</Directory>
Use the HTTP Server Configuration and Administration forms to create a new server instance named rpgconfig. Associate the instance with the configuration file you created.
Start the rpgconfig instance.
From your browser type: http://yourservername ort/html/samplerpg.html.
The input for this program comes from CGI standard input or the environment variable QUERY_STRING. For an HTTP request method of POST, the input is read from standard input and for an HTTP request method of GET, the input is read from QUERY_STRING. For method POST, this program will only read 1024 characters. For method GET, the program will not read any input data when it exceeds 1024 characters.
The program reads data from standard input based on the Content_Length environment variable. The QtmhGetEnv System API is used to get the Content_Length and set the InDataLn variable used by the QtmhRdStdIn API. The data to be returned to the client is written to standard output using the QtmhWrStOut API. The data is returned as text/html.
Gruss TARASIK
Similar Threads
-
By Stoeberl in forum NEWSboard Programmierung
Antworten: 8
Letzter Beitrag: 10-01-07, 10:58
-
By codierknecht in forum NEWSboard Java
Antworten: 7
Letzter Beitrag: 23-03-05, 08:31
-
By mk in forum IBM i Hauptforum
Antworten: 0
Letzter Beitrag: 09-09-04, 08:22
-
By hs in forum IBM i Hauptforum
Antworten: 14
Letzter Beitrag: 09-10-01, 12:06
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks