[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AW: question about example 2



   Hi Thomas - I've attached the source for EXAMPLE5.
   I can't figure out how to use it to POST data to the web form, and I
   suspect that it involves using some of the code in EXAMPLE2, which I've
   also attached.   I guess I am trying to combine the two of them into
   something which will POST several fields to a web form (like EXAMPLE 2
   does with fromAddr, subject, and message) , and put what was returned
   by the web site into data that I can manipulate (like EXAMPLE 5 foes
   with retdata)
   Larry Kleinman
   Kleinman Associates, Inc.
   212-949-6469
   From:        Thomas Raddatz <thomas.raddatz@xxxxxx>
   To:        "'HTTPAPI and FTPAPI Projects'"
   <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
   Date:        03/24/2015 08:46 AM
   Subject:        AW: question about example 2
   Sent by:        ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
     __________________________________________________________________

   Larry,
   It was great if you could send the source to me, since I do not have an
   archive of 1.23. The oldest archive I have is 1.25.
   Thomas.
   -----Ursprüngliche Nachricht-----
   Von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [[1]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] Im Auftrag von Larry
   Kleinman
   Gesendet: Dienstag, 24. März 2015 13:28
   An: HTTPAPI and FTPAPI Projects
   Cc: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   Betreff: Re: question about example 2
   Yep, I am using the same version.   Thomas, do you need me to send you
   the
   source, or can you find it in an archive of version 1.23
   Larry Kleinman
   Kleinman Associates, Inc.
   212-949-6469
   From:   Thomas Bishop <tbishop2@xxxxxxxxxx>
   To:     "ftpapi@xxxxxxxxxxxxxxxxxxxxxx"
   <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,
   Date:   03/24/2015 08:08 AM
   Subject:        Re: question about example 2
   Sent by:        ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   My copy of EXAMPLE5 also uses "raw".  Version 1.23
   Comment at top of EXAMPLE5 source code states:
   * This performs the same example as EXAMPLE4, except that it
   * uses the "raw" versio of http_url_post(). The advantage is
   * that data is received directly into a variable in the program
   * instead of writing it to the IFS.
   Source code contains the following:
   c                   eval      rc=http_url_post_raw(
   c                             'https://wwwcie.ups.com/ups.app' +
   c                             '/xml/Track':
   c                              %addr(data): %len(%trimr(data)):
   c                              1: %paddr('INCOMING'))
   c                   if        rc <> 1
   c                   eval      msg = http_error
   c                   dsply                   msg
   c                   return
   c                   endif
   The information transmitted is intended only for the person or entity
   to which it is addressed and may contain CONFIDENTIAL material.  If you
   receive this material/information in error, please contact the sender
   and delete or destroy the material/information.
   -----------------------------------------------------------------------
   This is the FTPAPI mailing list.  To unsubscribe, please go to:
   [2]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------
   --
   IMPORTANT NOTICE:
   This email is confidential, may be legally privileged, and is for the
   intended recipient only. Access, disclosure, copying, distribution, or
   reliance on any of it by anyone else is prohibited and may be a
   criminal offence. Please delete if obtained in error and email
   confirmation to the sender.
   -----------------------------------------------------------------------
   This is the FTPAPI mailing list.  To unsubscribe, please go to:
   [3]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------

References

   1. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   2. http://www.scottklement.com/mailman/listinfo/ftpapi
   3. http://www.scottklement.com/mailman/listinfo/ftpapi
ÿþ  5761WDS V6R1M0  080215                  SEU SOURCE LISTING                            03/24/15 10:48:47    KANYC800     PAGE    1

  SOURCE FILE . . . . . . .  LIBHTTP/QRPGLESRC

  MEMBER  . . . . . . . . .  EXAMPLE2

  SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0

    100      H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')                                                            03/23/06

    200                                                                                                                 11/03/04

    300       *                                                                                                         11/03/04

    400       * When form data is sent to a web browser, it often has to be                                             08/23/07

    500       * 'encoded'. HTTPAPI contains some routines called 'WEBFORM'                                              08/23/07

    600       * routines to help you with that encoding.                                                                08/23/07

    700       *                                                                                                         11/03/04

    800       * This demonstrates using HTTPAPI's WEBFORM functions                                                     08/23/07

    900       * to submit a web form.                                                                                   11/03/04

   1000       *                                                                                                         11/03/04

   1100       * Note that this program performs the same function that your                                             11/03/04

   1200       * web browser would if you pointed it to:                                                                 11/03/04

   1300       *     http://www.scottklement.com/comment/                                                                11/03/04

   1400                                                                                                                 10/21/01

   1500       /define WEBFORMS                                                                                          08/23/07

   1600      D/copy qrpglesrc,httpapi_h                                                                                 03/23/06

   1700                                                                                                                 10/21/01

   1800      D cmd             pr                  extpgm('QCMDEXC')                                                    10/21/01

   1900      D  command                     200A   const                                                                10/21/01

   2000      D  length                       15P 5 const                                                                10/21/01

   2100                                                                                                                 10/21/01

   2200      D CRLF            C                   CONST(x'0D25')                                                       10/21/01

   2300      D rc              s             10I 0                                                                      10/21/01

   2400      D msg             s             52A                                                                        10/21/01

   2500                                                                                                                 11/03/04

   2600      D Form            s                   like(WEBFORM)                                                        08/23/07

   2700      D fromAddr        s            100A   varying                                                              11/03/04

   2800      D Subject         s            100A   varying                                                              11/03/04

   2900      D Message         s           1000A   varying                                                              11/03/04

   3000      D myPointer       s               *                                                                        11/03/04

   3100      D dataSize        s             10I 0                                                                      11/03/04

   3200                                                                                                                 11/03/04

   3300       **                                                                                                        11/03/04

   3400       ** CHANGE THIS TO YOUR E-MAIL ADDRESS:                                                                    11/03/04

   3500       **                                                                                                        11/03/04

   3600      c                   eval      FromAddr = 'example2@scottklement.com'                                       04/26/07

   3700                                                                                                                 11/03/04

   3800       **                                                                                                        11/03/04

   3900       ** CHANGE THIS TO THE SUBJECT YOU'D LIKE SENT TO ME:                                                      11/03/04

   4000       **                                                                                                        11/03/04

   4100      c                   eval      Subject = 'EXAMPLE2 from HTTPAPI.'                                           11/03/04

   4200                                                                                                                 11/03/04

   4300       **                                                                                                        11/03/04

   4400       ** CHANGE THIS TO THE MESSAGE YOU'D LIKE SENT TO ME:                                                      11/03/04

   4500       **                                                                                                        11/03/04

   4600      c                   eval      Message = 'Hi Scott!' + CRLF +                                               11/03/04

   4700      c                             '  Just a note to tell you that I''m '+                                      11/03/04

   4800      c                             'testing out the EXAMPLE2 program in '+                                      11/03/04

   4900      c                             'HTTPAPI.  If you receive this, it ' +                                       11/03/04

   5000      c                             'must work!' + CRLF                                                          11/03/04

   5100                                                                                                                 11/03/04

   5200                                                                                                                 11/03/04

   5300       **                                                                                                        11/03/04

  5761WDS V6R1M0  080215                  SEU SOURCE LISTING                            03/24/15 10:48:47    KANYC800     PAGE    2

  SOURCE FILE . . . . . . .  LIBHTTP/QRPGLESRC

  MEMBER  . . . . . . . . .  EXAMPLE2

  SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0

   5400       ** When a program emulates a form on an HTML page, it's called                                            08/23/07

   5500       ** a 'webform' in HTTPAPI.  You must first open a new web                                                 08/23/07

   5600       ** form, and then set variables in it:                                                                    08/23/07

   5700       **                                                                                                        11/03/04

   5800      C                   eval      Form = WEBFORM_open                                                          08/23/07

   5900                                                                                                                 11/03/04

   6000      c                   callp     WEBFORM_SetVar(Form: 'from': fromAddr )                                      08/23/07

   6100      c                   callp     WEBFORM_SetVar(Form: 'subject': subject)                                     08/23/07

   6200      c                   callp     WEBFORM_SetVar(Form: 'Comment': message)                                     08/23/07

   6300                                                                                                                 10/21/01

   6400       **                                                                                                        11/03/04

   6500       ** The WEBFORM_postData() routine retrieves data suitable for                                             08/23/07

   6600       ** the http_url_post() API.  (there's also a WEBFORM_getData()                                            08/23/07

   6700       ** if you need to call HTTP_url_get).                                                                     08/23/07

   6800       **                                                                                                        11/03/04

   6900      c                   callp     WEBFORM_postData( Form : myPointer                                           08/23/07

   7000      c                                                    : dataSize )                                          11/03/04

   7100                                                                                                                 11/03/04

   7200       **                                                                                                        11/03/04

   7300       **  The http_url_post() function does an HTTP POST operation                                              11/03/04

   7400       **  sending any data at the pointer you specify.                                                          11/03/04

   7500       **                                                                                                        11/03/04

   7600       **  The results, in this case, are saved to the IFS in a file                                             11/03/04

   7700       **  called '/tmp/testpost.html'                                                                           11/03/04

   7800       **                                                                                                        11/03/04

   7900      c                   eval      rc = http_url_post(                                                          10/21/01

   8000      c                              'http://www.scottklement.com/cgi-bin/' +                                    11/03/04

   8100      c                                  'email_comment.cgi'                                                     11/03/04

   8200      c                             : myPointer                                                                  11/03/04

   8300      c                             : dataSize                                                                   11/03/04

   8400      c                             : '/tmp/testpost.html'                                                       11/21/07

   8500      c                             : HTTP_TIMEOUT                                                               11/21/07

   8600      c                             : HTTP_USERAGENT                                                             11/21/07

   8700      c                             : 'application/x-www-form-urlencoded' )                                      11/21/07

   8800                                                                                                                 04/09/07

   8900      c                   if        rc = 302                                                                     04/09/07

   9000      c                   eval      rc = http_url_get( http_redir_loc                                            09/04/07

   9100      c                                          : '/tmp/testpost.html')                                         04/09/07

   9200      c                   endif                                                                                  04/09/07

   9300                                                                                                                 10/21/01

   9400      c                   if        rc <> 1                                                                      10/21/01

   9500      c                   eval      msg = http_error                                                             10/21/01

   9600      c                   dsply                   msg                                                            10/21/01

   9700      c                   else                                                                                   10/21/01

   9800      c                   callp     cmd('DSPF ''/tmp/testpost.html''': 200)                                      11/03/04

   9900      c                   endif                                                                                  10/21/01

  10000                                                                                                                 11/03/04

  10100       **                                                                                                        11/03/04

  10200       ** When done, make sure you call this function to free up                                                 11/03/04

  10300       ** the memory that the web form used                                                                      08/23/07

  10400       **                                                                                                        11/03/04

  10500      c                   callp     WEBFORM_close(Form)                                                          08/23/07

  10600                                                                                                                 10/21/01

  5761WDS V6R1M0  080215                  SEU SOURCE LISTING                            03/24/15 10:48:47    KANYC800     PAGE    3

  SOURCE FILE . . . . . . .  LIBHTTP/QRPGLESRC

  MEMBER  . . . . . . . . .  EXAMPLE2

  SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0

  10700      c                   eval      *inlr = *on                                                                  10/21/01

                                  * * * *  E N D  O F  S O U R C E  * * * *

ÿþ  5761WDS V6R1M0  080215                  SEU SOURCE LISTING                            03/24/15 10:47:48    KANYC800     PAGE    1

  SOURCE FILE . . . . . . .  LIBHTTP/QRPGLESRC

  MEMBER  . . . . . . . . .  EXAMPLE5

  SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0

    100       *                                                                                                         05/05/05

    200       * This performs the same example as EXAMPLE4, except that it                                              05/05/05

    300       * uses the "raw" versio of http_url_post(). The advantage is                                              05/05/05

    400       * that data is received directly into a variable in the program                                           05/05/05

    500       * instead of writing it to the IFS.                                                                       05/05/05

    600       *                                                                                                         05/05/05

    700       *                                                                                                         05/05/05

    800      H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')                                                            03/23/06

    900                                                                                                                 10/21/01

   1000      D/copy qrpglesrc,httpapi_h                                                                                 03/23/06

   1100                                                                                                                 10/21/01

   1200      D incoming        PR            10I 0                                                                      10/21/01

   1300      D   descriptor                  10I 0 value                                                                10/21/01

   1400      D   data                      8192A   options(*varsize)                                                    10/21/01

   1500      D   datalen                     10I 0 value                                                                10/21/01

   1600                                                                                                                 10/21/01

   1700      D rc              s             10I 0                                                                      10/21/01

   1800      D msg             s             52A                                                                        10/21/01

   1900      D CRLF            C                   CONST(x'0d25')                                                       10/21/01

   2000      D data            S           1024A                                                                        10/21/01

   2100      D tracknum        S             20A   inz('1Z12345E0390515214')                                            07/27/04

   2200      D retdata         S          32766A                                                                        10/21/01

   2300      D retlen          S             10I 0                                                                      10/21/01

   2400      D nextpos         S             10I 0 inz(1)                                                               10/21/01

   2500                                                                                                                 10/21/01

   2600      c                   eval      *inlr = *on                                                                  10/21/01

   2700                                                                                                                 10/21/01

   2800      C* OOh, let's track a package with UPS!                                                                    10/21/01

   2900      C*                                                                                                         10/08/04

   3000      C* FOR A BETTER EXAMPLE OF UPS PACKAGE TRACKING, SEE EXAMPLE16                                             10/08/04

   3100      c                   eval      data =                                                                       10/21/01

   3200      c                             '<?xml version="1.0"?>' + CRLF +                                             10/21/01

   3300      c                             '<TrackRequest xml:lang="en-US">' + CRLF+                                    10/21/01

   3400      c                             '<Request>' + CRLF +                                                         10/21/01

   3500      c                             '<TransactionReference>' + CRLF +                                            10/21/01

   3600      c                             '<CustomerContext>Example 1</Customer'+                                      10/21/01

   3700      c                             'Context>' + CRLF +                                                          10/21/01

   3800      c                             '<XpciVersion>1.0001</XpciVersion>'+CRLF+                                    10/21/01

   3900      c                             '</TransactionReference>' +                                                  10/21/01

   4000      c                             '<RequestAction>Track</RequestAction>'+                                      10/21/01

   4100      c                             CRLF +                                                                       10/21/01

   4200      c                             '<RequestOption>activity</Request' +                                         10/21/01

   4300      c                             'Option>' + CRLF +                                                           10/21/01

   4400      c                             '</Request>' + CRLF +                                                        10/21/01

   4500      c                             '<TrackingNumber>' +                                                         10/21/01

   4600      c                             %trim(tracknum) + '</TrackingNumber>'+                                       10/21/01

   4700      c                             CRLF + '</TrackRequest>' + CRLF                                              10/21/01

   4800                                                                                                                 10/21/01

   4900      C**  The only diff between using HTTPS and using HTTP is                                                   10/21/01

   5000      C**  the URL that we pass.  It starts with 'https://'                                                      10/21/01

   5100      c                   eval      rc=http_url_post_raw(                                                        10/21/01

   5200      c                             'https://wwwcie.ups.com/ups.app' +                                           07/27/04

   5300      c                             '/xml/Track':                                                                07/27/04

  5761WDS V6R1M0  080215                  SEU SOURCE LISTING                            03/24/15 10:47:48    KANYC800     PAGE    2

  SOURCE FILE . . . . . . .  LIBHTTP/QRPGLESRC

  MEMBER  . . . . . . . . .  EXAMPLE5

  SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0

   5400      c                              %addr(data): %len(%trimr(data)):                                            07/27/04

   5500      c                              1: %paddr('INCOMING'))                                                      07/27/04

   5600      c                   if        rc <> 1                                                                      10/21/01

   5700      c                   eval      msg = http_error                                                             10/21/01

   5800      c                   dsply                   msg                                                            10/21/01

   5900      c                   return                                                                                 10/21/01

   6000      c                   endif                                                                                  10/21/01

   6100                                                                                                                 10/21/01

   6200      C* convert the data we just received to EBCDIC                                                             10/21/01

   6300      c                   if        retlen > 1                                                                   10/21/01

   6400      c                   callp     http_xlate(retlen: retdata: TO_EBCDIC)                                       06/23/05

   6500      c                   endif                                                                                  10/21/01

   6600                                                                                                                 10/21/01

   6700      C* now the returned data is in the 'retdata' string.                                                       10/21/01

   6800      C*  run this program in debug and display retdata....  you'll see...                                       10/21/01

   6900      c                   return                                                                                 10/21/01

   7000                                                                                                                 10/21/01

   7100                                                                                                                 10/21/01

   7200      P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                       10/21/01

   7300      P*  this procedure will receive the raw data received from UPS                                             10/21/01

   7400      P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                       10/21/01

   7500      P incoming        B                                                                                        10/21/01

   7600      D incoming        PI            10I 0                                                                      10/21/01

   7700      D   descriptor                  10I 0 value                                                                10/21/01

   7800      D   data                      8192A   options(*varsize)                                                    10/21/01

   7900      D   datalen                     10I 0 value                                                                10/21/01

   8000                                                                                                                 10/21/01

   8100      C* Make sure we don't overflow the string:                                                                 10/21/01

   8200      c                   eval      retlen = (nextpos + datalen) - 1                                             10/21/01

   8300      c                   if        retlen > %size(retdata)                                                      10/21/01

   8400      c                   eval      datalen=datalen-(retlen-%size(retdata))                                      09/22/04

   8500      c                   endif                                                                                  10/21/01

   8600                                                                                                                 10/21/01

   8700      C* If there is nothing to write, return THAT...                                                            10/21/01

   8800      c                   if        datalen < 1                                                                  10/21/01

   8900      c                   return    0                                                                            10/21/01

   9000      c                   endif                                                                                  10/21/01

   9100                                                                                                                 10/21/01

   9200      C* Here we add any data sent to the end of our 'retdata' string:                                           10/21/01

   9300      c                   eval      %subst(retdata: nextpos) =                                                   10/21/01

   9400      c                                %subst(data:1:datalen)                                                    10/21/01

   9500      c                   eval      nextpos = nextpos + datalen                                                  10/21/01

   9600                                                                                                                 10/21/01

   9700      c* We always return the amount of data that we wrote.   Note                                               10/21/01

   9800      C*  that if http-api sees that we didn't write as much data as                                             10/21/01

   9900      C*  it sent us, it'll abort the process with an error message.                                             10/21/01

  10000      c                   return    datalen                                                                      10/21/01

  10100      P                 E                                                                                        10/21/01

                                  * * * *  E N D  O F  S O U R C E  * * * *

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------