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

Attempt at a UPS PLD posting



   Hello,

   I had issues with my UPS PLD posting where no UPS response was given
   due to my limited knowledge of HTTP and SOCKET calls.


   I came across the following e-mail from your archives website and used
   the coding example from the e-mail as inspiration to correct the past
   issues with my UPS PLD posting:

               Subject Problem with HTTP POST REQUEST

               From Bruno Souche

               Date Wednesday, January 24^th, 2007  10:22:29 +0100


   I now see a UPS response from my UPS PLD posting albeit a response
   with errors.


   According to UPS Host Access Support, the code that I am currently
   using appears to be sending data as a HTTP form submit (this is the
   same as loading a page in an Internet browser) and clicking the
   "Submit" button on a displayed page.  UPS is requesting an HTTP POST
   using a socket program that will stream the body of a request in the
   UPS required format.  If I understand UPSs remarks correctly, I need
   to submit and receive the UPS data in a behind-the-scenes manner.


   At your earliest convenience, please let me know if there are
   utilities or coding that I need to add or remove in order to
   communicate to UPS properly.  I have attached the RPG ILE code along
   with the corresponding send and receive scripts.  If additional
   information is needed from me, please let me know.

   Thank you,
   Nick
     _________________________________________________________________

   Get more out of the Web. Learn 10 hidden secrets of Windows Live.
   [1]Learn Now

References

   1. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_getmore_092008
     H BndDir('HTTPAPI')
     ?**************************************************************************
     ?*_> CRTRPGMOD MODULE(EMT_LIB/SENDUPSEMT) SRCFILE(SRC_LIB/SRC_FILE) +
     ?*_>   SRCMBR(*MODULE) DBGVIEW(*ALL) CVTOPT(*VARCHAR)

     ?*_> CRTPGM PGM(EMT_LIB/SENDUPSEMT) MODULE(SENDUPSEMT) +
     ?*_>   ENTMOD(SENDUPSEMT) ACTGRP(QILE)
     ?*************************************************************************
     FPLDTESTSGFIF   E             DISK
     FHTTPLOG   O    E             DISK    USROPN
     ?**************************************************************************
     D/copy qrpglesrc,httpapi_h
     ?*------------------------------------------------------------------------*
     D Cmd             PR                  ExtPgm('QCMDEXC')
     D  Command                     200A   Const
     D  Length                       15P 5 Const

     D CRLF            C                   CONST(x'0d25')
     D Data            S          32767A    Varying
     D Long            S             10  0
     D Msg             S             52A
     D rc              S             10I 0
     D retdata         S          32766A
     D retlen          S             10I 0
     D nextpos         S             10I 0 inz(1)
     ?*************************************************************************
     C                   Eval      *InLR       = *On
     ?*------------------------------------------------------------------------*
      /Free
        Data = 'POST /hapld/tos/kdwhapltos HTTP/1.1' + CRLF;

        Data = Data + 'Host: www.pld-certify.ups.com' + CRLF;

        Data = Data + 'Content-type: multipart/mixed; boundary=BOUNDARY' + CRLF;

        Data = Data + 'Content-length: 1261' + CRLF + CRLF;

        Data = Data + '--BOUNDARY' + CRLF;

        Data = Data + 'Content-type: application/x-www-form-urlencoded' + CRLF;

        Data = Data + 'Content-length: 131' + CRLF + CRLF;

        Data = Data + 'AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&';

        Data = Data + 'ResponseType=application/x-ups-pld&VersionNumber=';

        Data = Data + 'V4R1&UserId=LOG001CA&Password=LOGICOR' + CRLF;

        Data = Data + CRLF + '--BOUNDARY' + CRLF;

        Data = Data + 'Content-type: application/x-ups-binary' + CRLF;

        Data = Data + 'Content-length: 1014' + CRLF + CRLF;

         read UPHPLDR;
         data = data + %Trim(PLFLD);
         read UPHPLDR;
         data = data + %Trim(PLFLD);
         data = data + CRLF + CRLF;

        Data = Data + '--BOUNDARY--' + CRLF;
      /End-Free
     C                   If        Not %Open(HttpLog)
     C                   Open      HttpLog
     C                   EndIf
pkf  C                   Eval      LOG         = %Trim(Data)
pkf  C                   Write     LOGREC
     C                   Close     HttpLog
     ?*------------------------------------------------------------------------*
      ** The only diff between using HTTPS and using HTTP is
      ** the URL that we pass. It starts with 'https://'

     C                   Eval      Long = %Len(Data)
     C     Long          Dsply

     C                   Eval      rc   = http_url_post(
     C                                     'https://www.pld-certify.ups.com/'
     C                                        : %Addr(Data)
     C                                        : %Len(%TrimR(Data))
     C                                        : '/tmp/httptest.html')
     C                   If        rc  <> 1
     C                   Eval      msg  = http_error
     C                   Dsply                   msg
     C                   Return
     C                   EndIf

     ** This should be the XML data that UPS returns to us:

     C                   Callp     cmd('DSPF ''/tmp/httptest.html''': 200)
     C                   Return
   --BOUNDARY Content-type: text/html Content-length: 138

   UPS Internet Software, Copyright UPS 1998
   --BOUNDARY Content-type: application/x-ups-psmpld Content-length: 104
   UPSOnLine%null%6931%6811Content-Type invalid. --BOUNDARY Content-type:
   application/x-ups-pld Content-length: 110
   00010000009710000008800026811Content-Type invalid. --BOUNDARY--
POST /hapld/tos/kdwhapltos HTTP/1.1
Host: www.pld-certify.ups.com
Content-type: multipart/mixed; boundary=BOUNDARY
Content-length: 1261

--BOUNDARY
Content-type: application/x-www-form-urlencoded
Content-length: 131

AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-ups-pld&VersionNumber=V4R1&UserId=LOG001CA&Password=LOGICOR

--BOUNDARY
Content-type: application/x-ups-binary
Content-length: 1014

020020                                  2004011300000000769907200   000000001*AAV69W42    US                0007699072000001*BA1ZV69W42A600058508                 00001+0000000000000100 +0000000000000100LBS02PRE10                                   3INUSD000001*CA18CONT SDC03                         BOB WATSON                         8000 JEFFREY DRIVE                 SUITE 200                                                             BEVERLY HILLS                 CA   90210    US12133455533                                             *EARLIHD1900    *FA001PO12345                              *FA002STSDS03                              *PA1ZV69W42A600058508                 02+0000100                                                  DOC+0000100+00000000+00000000+00000000*EAEVS+000000000000300000USD*EAADS*FA003PO12345                              *FA004STSDS03                              *FA005TNSCENARIO 3                         *SA000012

--BOUNDARY--

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