Skip to main content  
        iSeries home   |   Easy400  
Public-Source
 
Introduction
 
 Client side
Server side
 
 Download
 
 

 
ez4WebServ
IBM i WEB Services
Client side

EZ4WEBSERV features some client commands for receiving the WEB server response script in an IFS stream file:

  1. URLGET
  2. URLPST
  3. URLPSTSTMF
  4. HTTPDEBUG
Once the WEB server response has been received in the specified stream file, the subsequent process is up to the developer.
If the received stream file contains an XML script, then some XML parsing utility may be used to process the data.
Easy400.net provides an utility, named EZ4PARSE that uploads the XML data to an appropriate database file. In this way the further processing of the received data results quite obvious.
Note. All the above commands use Scott Klement's HTTP API (library LIBHTTP).


 

1-Command URLGET

Use this command to receive a WEB page into a user-specified IFS stream file.

                            Retrieve a HTTP document (URLGET)
 Type choices, press Enter.
  
 URL  . . . . . . . . . . . . . . URL          >                                             
                                                                                
                                                                                
 Username . . . . . . . . . . . . USERNAME     > *NONE                                       
                                                                                
 Password . . . . . . . . . . . . PASSWORD                                                   
                                    
 Stream file receiving response   STMF                                                       
                                                                                
 Stream file CCSID  . . . . . . . STMFCCSID      *ASCII         Number, *ASCII, *JOB
 Display stream file  . . . . . . DSPSTMF        *NO           *YES, *NO
 Content-type . . . . . . . . . . CONT_TYPE                                                  
                                    
 SOAP action  . . . . . . . . . . SOAP_ACT       *NONE                                       
                                    

Command URLGET

  • URL (URL):
    Type the same URL that you would enter to request a CGI page from a WEB browser.
  • Username (USERNAME):
    If the access to the URL needs to be validated with username and password, enter the username here and the password in parameter PASSWORD.
    If no access validation is requestedby the URL, leave *NONE for the username.
  • Password (PASSWORD):
    If parameter USERNAME is not *NONE, a password must be entered.
    Note that username and password are case sensitive.
  • Stream file receiving response (STMF):
    Path and name of the IFS stream file that will receive the WEB page.
    Example: /tmp/cgidev2_home.html
    Please note the following:
    1. The stream file does not have to exsist already. It is automatically created. If already existing, it is deleted and re-created.
    2. It is a user / program responsibility to delete this stream file when no longer needed.
  • Stream file CCSID (STMFCCSID):
    CCSID to be assigned to the stream file.This CCSID must match the CCSID of the page returned by the URL. Usually the CCSID returned by the URL is ASCII 819, understood by Personal Computers.
    • *ASCII assigns CCSID 819 (US ASCII)
    • *JOB assigns the job default CCSID
  • Display stream file (DSPSTMF):
    Whether the stream file should be displayed after having been received from the CGI program.
  • Content-type (CONT-TYPE):
    Content type to supply (mainly useful when talking to CGI scripts).
    You may supply its default value "text/xml" .
  • SOAP action (SOAP_ACT):
    If the remote WEB Server is a SOAP one, providing a "SOAP action" parameter is mandatory. This parameter is a field in the "HTTP request header" and indicates the intent of the SOAP HTTP request. The value is a URI identifying the intent. SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. Examples:
    • 'http://electrocommerce.org/abc#MyMessage'
    • 'myapp.sdl'
    • ' '
    When the WEB Server is not a SOAP one, leave SOAPACTION(*NONE).

Completion messages

  • If the command is executed without problems, the following message is sent to the joblog:
    WEB Server response received in stmf '...'
  • If the command is not successful, an escape message terminates the process and appears in the joblog. Example: *** HTTPAPI internal error no. 36: This page requires a user-id & password.

Examples:
HTTP EZ4WEBSERV/URLGET
URL('http://cgidev2.easy400.net/cgidev2p/hello1.pgm?firstname=G&lastname=Burr')
STMF('/tmp/URLGET_cgidev2.txt') DSPSTMF(*YES)
HTTPS EZ4WEBSERV/URLGET
URL('https://en.wikipedia.org/wiki/Cgidev2')
STMF('/tmp/URLGET_wikipedia.txt') DSPSTMF(*YES)



 

2-Command URLPST

Use this command to post a form to a CGI program and to receive the CGI response (usually a HTML page) into a user specified IFS stream file.

                    Post data to CGI, get document (URLPST)                   

 Type choices, press Enter.
  
 URL  . . . . . . . . . . . . . . URL          >                                             
                                                                                
                                                                                
 Username . . . . . . . . . . . . USERNAME     > *NONE                                       
                                    
 Password . . . . . . . . . . . . PASSWORD                                                   
                                    
 Stream file receiving response   STMF                                                       
                                                                                
 Stream file CCSID  . . . . . . . STMFCCSID      *ASCII        Number, *ASCII, *JOB
 Display stream file  . . . . . . DSPSTMF        *NO           *YES, *NO
 URL input variables:             INPVAR        
   'variable name'  . . . . . . .                                            
   'variable value' . . . . . . .                                                            
                                                                                
        
                             + for more values  
 No. of sec.s before giving up  . TIMEOUT        30            5-3600
 Content-type . . . . . . . . . . CONT_TYPE                                                  
                                                 
 SOAP action  . . . . . . . . . . SOAP_ACT                                                   
                                                  

Command URLPST

  • URL (URL):
    Type the same URL that you would enter to request a CGI page from a WEB browser.
    Note: If input variables are required, do not add them to the URL. They must instead be specified in parameter INPVAR.
  • Username (USERNAME):
    If the access to the URL needs to be validated with username and password, enter the username here and the password in parameter PASSWORD.
    If no access validation is requestedby the URL, leave *NONE for the username.
  • Password (PASSWORD):
    If parameter USERNAME is not *NONE, a password must be entered.
    Note that username and password are case sensitive.
  • Stream file receiving response (STMF):
    Path and name of the IFS stream file that will receive the CGI response (the WEB page).
    Example: /tmp/hello.html
    Please note the following:
    1. The stream file does not have to exsist already. It is automatically created. If already existing, it is deleted and re-created.
    2. It is a user / program responsibility to delete this stream file when no longer needed.
  • Stream file CCSID (STMFCCSID):
    CCSID to be assigned to the stream file.This CCSID must match the CCSID of the page returned by the URL. Usually the CCSID returned by the URL is ASCII 819, understood by Personal Computers.
    • *ASCII assigns CCSID 819 (US ASCII)
    • *JOB assigns the job default CCSID
  • Display stream file (DSPSTMF):
    Whether the stream file should be displayed after having been received from the CGI program.
  • URL input variables (INPVAR):
    Use this parameter to specify any variables - and their values - input to the CGI program.
    Up to 50 input variables can be specified. For each of them enter:
    1. the name of the variable (up to 30 characters)
    2. the value of the variable (up to 100 characters)
    Example: INPVAR(('firstname' 'George') ('lastname' 'Brown'))
  • No. of sec.s before giving up (TIMEOUT):
    Give up if no data is received for this many seconds.
  • Content-type (CONT_TYPE):
    (Optional) - Content type to supply (mainly useful when talking to CGI scripts).
  • SOAP action (SOAP_ACT):
    (Optional) - String used to specify the action taken by some SOAP applications.

Completion messages

  • If the command is executed without problems, the following message is sent to the joblog:
    WEB Server response received in stmf '...'
  • If the command is not successful, an escape message terminates the process and appears in the joblog. Example: *** HTTPAPI internal error no. 36: This page requires a user-id & password.

Examples:
HTTP EZ4WEBSERV/URLPST
URL('http://cgidev2.easy400.net/cgidev2p/hello1.pgm')
STMF('/tmp/URLPST_cgidev2.txt') DSPSTMF(*YES)
INPVAR((firstname 'George') (lastname 'Brown'))
HTTPS EZ4WEBSERV/URLPST
URL('https://en.wikipedia.org/w/index.php')
STMF('/tmp/URLPST_wikipedia.txt') DSPSTMF(*YES)
INPVAR((search 'Giovanni Perotti') (Special 'Special:Search') (go 'Go'))
Command:
EZ4WEBSERV/URLPST URL('https://test.monetaonline.it/monetaweb/payment/2/xml')
  STMF('/tmp/urlpst.txt') DSPSTMF(*YES)
  INPVAR(('id' '99999999') ('password' 99999999) ('operationType' 'initialize')
   ('amount' '1.00') ('currencyCode' '978') ('language' 'ITA')
   ('responseToMerchantUrl' 'https://ecommerce.touchcut.com/cgi/payment?r=')
   ('recoveryUrl' 'https://ecommerce.touchcut.com/error.cgi')
   ('merchantOrderId' 'mmm...mmm') ('description' 'ddd...ddd')
   ('cardHolderName' ' ') ('cardHolderEmail' 'some...Email')
   ('customField' 'customized...Field'))
  CONT_TYPE('application/x-www-form-urlencoded')

Response
************Beginning of data**************
<response>
<paymentid>859865093723173329</paymentid>
<hostedpageurl>https://test.monetaonline.it/monetaweb/page/hosted/2/html</hostedpageurl>
<securitytoken>c5693fae495246ae881dda6cdb4eae77</securitytoken>
</response>
************End of Data********************



 

3-Command URLPSTSTMF

This command posts a stream file to a given URL and receives back a document into a user-specified IFS stream file.

                         Post XML stmf, get response (URLPSTSTMF)

  Type choices, press Enter.

 URL  . . . . . . . . . . . . . . URL                                                     
                                                                                          
                                                                                          
                                                                 
 Username . . . . . . . . . . . . USERNAME    *NONE                                       
                                              
 Password . . . . . . . . . . . . PASSWORD                                                
                                    
 Stream file sent . . . . . . . . STMFIN                                                  
                 
 Content-type . . . . . . . . . . CONT_TYPE   'text/xml'                                  
                                              
 SOAP action  . . . . . . . . . . SOAP_ACT    *NONE                                       
                                              
 Received stream file . . . . . . STMFOUT                                                 
                                              
 CCSID of received stream file  . CCSIDOUT    *ASCII          Number, *ASCII, *JOB
 Display received stream file . . DSPOUT      *YES            *YES, *NO

Command URLPSTSTMF

  • URL (URL):
    URL where the stream file should be posted.
    Example:
    http://www.webservicex.net/CurrencyConvertor.asmx
  • Username (USERNAME):
    If the access to the URL needs to be validated with username and password, enter the username here and the password in parameter PASSWORD.
    If no access validation is requestedby the URL, leave *NONE for the username.
  • Password (PASSWORD):
    If parameter USERNAME is not *NONE, a password must be entered.
    Note that username and password are case sensitive.
  • Stream file sent (STMFIN):
    Path and name of the stream file to be sent.
    Note.The contents of the stream file must be compatible with the WEB service provided at the given URL. Usually a SOAP script in XML format is expected.
  • Content-type (CONT_TYPE):
    Content-type of the stream file being sent.
  • SOAP action (SOAP_ACT):
    If the remote WEB Server is a SOAP one, providing a "SOAP action" parameter is mandatory. This parameter is a field in the "HTTP request header" and indicates the intent of the SOAP HTTP request. The value is a URI identifying the intent. SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. Examples:
    • 'http://electrocommerce.org/abc#MyMessage'
    • 'myapp.sdl'
    • ' '
  • Received stream file (STMFOUT):
    Path and name of the IFS stream file that will receive the WEB server response script.
    Example:
    /tmp/response.xml
    Please note the following:
    1. The stream file does not have to exsist already. It is automatically created. If already existing, it is deleted and re-created.
    2. It is a user / program responsibility to delete this stream file when no longer needed.
  • CCSID of received stream file (CCSIDOUT):
  • Display received stream file (DSPOUT):
    Whether the received stream file should be displayed after having been received.

Completion messages

  • If the command is executed without problems, the following message is sent to the joblog:
    WEB Server response received in stmf '...'
  • If the command is not successful, an escape message terminates the process and appears in the joblog.

Example:
URLPSTSTMF URL('http://www.webservicex.net/CurrencyConvertor.asmx')
 STMFIN('/ez4webserv/soap_docs/example01.txt') CONT_TYPE('text/xml')
 SOAP_ACT('http://www.webserviceX.NET/ConversionRate')
 STMFOUT('/tmp/currencyExchange.txt')



 

4-Command HTTPDEBUG

Scott Klement's HTT API's include the ability to maintain a log of communications between Client and Server. This log can be of some help in solving communication problems. Besides, it provides some interesting insight of what is going on.

Command EZ4WEBSERV/HTTPDEBUG features the following options:

  • *ON - Enables writing to the communications log
  • *OFF - Disables writing to the communications log
  • *DSP - Displays the communications log
  • *CLR - Clears the communications log