[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    Jul 2003
    Beiträge
    63

    Question HTTP-Aufruf aus RPG; (wie) geht das ?

    Hallo zusammen,

    ich muß aus einem RPG-Pgm Parameter (Kreditkartennummer etc.) an eine URL über HTTP übergeben und das Ergebnis einer Prüfung empfangen. Es handelt sich bei dem RPG um einen Dialog, in dem das Ergebnis der Kartenprüfung angezeigt werden soll. Kommunikation mit der prüfenden Instanz erfolgt über virtuelle Internetsite. Geht das überhaupt, und wenn ja, wie ??

    Im Voraus vielen Dank für Eure Mühe

    Klaus Hardy

  2. #2
    Registriert seit
    May 2002
    Beiträge
    2.642

    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://yourservernameort/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

  3. #3
    Registriert seit
    May 2002
    Beiträge
    2.642

  4. #4
    Registriert seit
    Jan 2001
    Beiträge
    340
    noch'n link

    Easy400 CGI WEB development tools for iSeries

    The Easy400 site provides free tools that enable RPG and COBOL programmers to develop full-functional e-business solutions by just exploiting their current skills.

    All tools are delivered with sources.

    http://www-922.ibm.com/en

    Gruß
    Rolf

  5. #5
    Registriert seit
    Feb 2001
    Beiträge
    20.241
    Dies sind ja alles schöne Hinweise, wie ich RPG als CGI o.ä. nutzen kann, aber ich verstehe die Frage so:

    Wie kann ich von einem 5250-Dialog-Programm einen Zugriff über HTTP aufs Internet gestalten, um z.B. Kreditkarten prüfen zu lassen ?
    Dienstleistungen? Die gibt es hier: http://www.fuerchau.de
    Das Excel-AddIn: https://www.ftsolutions.de/index.php/downloads
    BI? Da war doch noch was: http://www.ftsolutions.de

  6. #6
    Registriert seit
    Dec 2000
    Beiträge
    99
    ...
    lässt sich mit etwas Aufwand 'zu Fuss'
    über Sockets lösen. Im RPG Programm
    den Port 80 des HttpServers öffen und
    den HTTP-Request als String zusammen-
    basteln und zum Server schicken. Die Response kann dann im RPG-Programm aus dem empfangenen HTML - String geparst werden. Beispiele unter

    http://klement.dstorm.net/rpg/socktut/

    Gruss

    Torsten

  7. #7
    Registriert seit
    Dec 2000
    Beiträge
    79

    HTTP aus RPG

    Hallo,

    bei www.help400.de/freeware.htm
    gibt es HTTPAPI, das in einem Serviceprogramm das gesamte Socket-Handling erledigt, lediglich die URL ist anzugeben.

    Thomas

  8. #8
    Registriert seit
    Jul 2003
    Beiträge
    63
    Vielen Dank für die umfangreichen Informationen.
    Das will nun alles erstmal verarbeitet werden und kann etwas dauern, bis ich eine Erfolgsmeldung geben kann.

    Zunächst aber folgendes:
    Es ist genau so gemeint, wie FUERCHAU schreibt !!

    Der Link von HORSCHMA führt leider ins Leere.

    Für weitere Anregungen dankbar

    Klaus

  9. #9
    Registriert seit
    May 2002
    Beiträge
    2.642

    LINK AUF API

    Hallo,
    hier den Link:

    http://www.help400.de/Freeware.htm#H

    Gruss TARASIK

Similar Threads

  1. Problem mit Java-Methoden Aufruf aus ILE RPG?
    By Stoeberl in forum NEWSboard Programmierung
    Antworten: 8
    Letzter Beitrag: 10-01-07, 10:58
  2. Aufruf von Java Methode aus RPG
    By codierknecht in forum NEWSboard Java
    Antworten: 7
    Letzter Beitrag: 23-03-05, 08:31
  3. Aufruf von Java Programm direkt aus RPG
    By mk in forum IBM i Hauptforum
    Antworten: 0
    Letzter Beitrag: 09-09-04, 08:22
  4. Frage zu RPG: Aufruf RPG-Programm mit Parametern
    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
  •