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

Re: Advice on how to process xsd:base64Binary XML element retrieved from a web service.



   Paul,
   You are short before success. The one and only problem with your
   program is that you write the length bytes of 'resultVar' to the IFS.
   Change the write statement as shown below and you are done:
         callp write(fd1
                   : %addr(resultVar: *DATA)
                   : %len(resultVar));
   You see "garbage" in 'resultVar' in the debugger, because the decoded
   Base64 data is encoded as UTF-8.
   Thomas.
   ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 19.12.2013 22:30:39:
   > Von: PReid@xxxxxxxxxxxx
   > An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx,
   > Datum: 19.12.2013 22:41
   > Betreff: Re: Advice on how to process xsd:base64Binary XML element
   > retrieved from a web service.
   > Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   >
   > Hello again.
   > I've ran into a bit of a roadblock with my little project. I've read
   and
   > tried everything can find and I'm feeling a bit stuck.
   > Here is my code - questions at the bottom.:
   >
   > H BNDDIR('HTTPAPI':'QC2LE')
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Program     : DSRPERFMON     *
   >       * Description : First kick at the can downloading Truck
   Performance
   > data *
   >       *             : through SHAW's ESS Web Service.     *
   >       * Programmer  : Paul Reid.     *
   >       * Date        : May 21,2013     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * WSDL :     *
   >       *
   [1]https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/
   >    *
   >       *  OTSWebSvcs.wsdl     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * SoapUI :     *
   >       *  Project Name      : ESS Web Services (PMESS)     *
   >       *   Interface Name   : OTSWebSvcsSoapBinding     *
   >       *    Operation name  : dequeue2     *
   >       *     Request name   : HighVolumeDequeue     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Revision History     *
   >       * ----------------     *
   >       * Revision #   : ini01    Date: mm/dd/yyyy    Programmer: name
       *
   >       * Changes made :     *
   >       * Reason       :     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Prototype call to this program:     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >      D DSRPERFMON      PR                  extpgm('DSRPERFMON')
   >      D lastTransaction...
   >      D                               17A
   >       *
   >      D DSRPERFMON      PI
   >      D lastTransaction...
   >      D                               17A
   >       *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * /copy Prototypes:     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >       * Used to consume a Web Service.
   >       /include qrpglesrc,httpapi_h
   >       *
   >       * Used to decode data encrypted in BASE64.
   >       /include qrpglesrc,base64_h
   >       *
   >       * For I/O with the IFS
   >       /include qrpglesrc,ifsio_h
   >       *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Incoming - Procedure to handle data retrieved from the Web
   > Service.    *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >      D Incoming        PR
   >      D  rate                          8F
   >      D  depth                        10I 0 value
   >      D  name                       1024A   varying const
   >      D  path                      24576A   varying const
   >      D  value                              likeds(Xmlstring_t)
   >      D  attrs                          *   dim(32767)
   >      D                                     const options(*varsize)
   >       *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Define local date structures:     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >      D XmlString_t...
   >      D                 DS                  qualified Template
   >      D  Data...
   >      D                                 *
   >      D  Len...
   >      D                               10i 0
   >       *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Define local variables:     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >       * Scott's variables.
   >      D SOAP            S          32767A   varying
   >      D rc              S             10I 0
   >      D rate            S              8F
   >      D Result          S             12P 2
   >       *
   >       * Used to assemble the XML SOAP request.
   >      D soapHeader...
   >      D                 S          32767A   varying
   >      D soapBody...
   >      D                 S          32767A   varying
   >       *
   >       * Log.
   >      D dequeue2Log...
   >      D                 S           1000A   varying
   >       *
   >       * Input variables for XML Request.
   >      D subscriberId...
   >      D                 S              9A   varying
   >      D transactionIdIn...
   >      D                 S             17A   varying
   >       *
   >       * Variables for Handling errors returned from the Web Service.
   >      D sendError...
   >      D                 S            102A   inz(*blanks)
   >      D peErrorNo...
   >      D                 S             10I 0 inz(*zeros)
   >      D errorMessage...
   >      D                 S            100A   inz(*blanks)
   >       *
   >       * Error flag.
   >      D didWeGetAnError...
   >      D                 S              3A   inz('No ')
   >       *
   >       * Data returned that is not encoded.
   >      D var...
   >      D                 S             50A   based(p_var)
   >      D count...
   >      D                 S              5P 0 inz(*zeros)
   >      D transactionIdOut...
   >      D                 S             17P 0 inz(*zeros)
   >       *
   >       * Encoded data returned.
   >      D resultVar...
   >      D                 S               A    len(2000000) varying
   >      D decodedLen...
   >      D                 S             10I 0
   >       *
   >       * Output data
   >      D fd1...
   >      D                 S             10I 0
   >      D len1...
   >      D                 S             10I 0
   >       *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Mainline:     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >       /free
   >
   >           // Assemble the SOAP Header.
   >           exsr assembleSOAPheader;
   >
   >           // Assemble the SOAP Body.
   >           exsr assembleSOAPbody;
   >
   >           // Assemble complete SOAP XML Request.
   >           SOAP = %trim(soapHeader) + %trim(soapBody);
   >
   >           // Write out to a Log in case we have problems.
   >           dequeue2Log = '/home/PAULRE/dequeue2Log.txt';
   >           http_debug(*ON : dequeue2Log);
   >
   >           // Change the way the XML parser returns the data.
   >           // We need to use pointer since it is so large.
   >           http_XmlReturnPtr(*on);
   >
   >           // Post Reqest.
   >           rc = http_url_post_xml(
   >               'https:
   > //www.myshawtracking.ca:443/otsWebWS/services/OTSWebSvcs'
   >              : %addr(SOAP) + 2
   >              : %len(SOAP)
   >              : *NULL
   >              : %paddr(Incoming)
   >              : %addr(rate)
   >              : HTTP_TIMEOUT
   >              : HTTP_USERAGENT
   >              : 'text/xml'
   >              : 'http://www.qualcomm.com/dequeue2');
   >
   >           // Success!
   >           if rc = 1;
   >
   >              // Output performance data to the IFS.
   >              fd1 = open('/home/PAULRE/perfDataXML.xml'
   >                       : O_RDWR+O_CREAT+O_TRUNC+O_CCSID
   >                       : 438
   >                       : 1208);
   >
   >              if fd1 < 0;
   >                 // There was an error creating/opening the IFS file.
   >
   >              else;
   >                 callp write(fd1 : %addr(resultVar) :
   > %len(%trim(resultVar)));
   >
   >                 if len1 < 1;
   >                    // There was an error writing to the IFS file.
   >                 else;
   >
   >                    // Parse out the performance data and
   >                    // write it into our database.
   >                    exsr parsePerfData;
   >                 endif;
   >                 callp close(fd1);
   >              endif;
   >
   >           // Send a message if we get an error.
   >           else;
   >              sendError = *on;
   >           endif;
   >
   >           // The End.
   >           *inlr = *on;
   >
   >
   >
   //---------------------------------------------------------------------
   --*
   >        // parsePerfData      *
   >
   >
   //---------------------------------------------------------------------
   --*
   >
   >           begsr parsePerfData;
   >           endsr;
   >
   >
   >
   //---------------------------------------------------------------------
   --*
   >        // assembleSOAPheader      *
   >
   >
   //---------------------------------------------------------------------
   --*
   >
   >           begsr assembleSOAPheader;
   >
   >           soapHeader =
   >           '<?xml version="1.0" encoding="utf-8"?>'
   >           +' <soap:Envelope'
   >           +'
   xmlns:soap="[2]http://schemas.xmlsoap.org/soap/envelope/";'
   >           +'
   xmlns:wsa="[3]http://schemas.xmlsoap.org/ws/2004/03/addressing";'
   >           +' xmlns:wsse="http:
   > //docs.oasis-open.org/wss/2004/01/oasis-200401-'
   >                        +'wss-wssecurity-secext-1.0.xsd"'
   >           +' xmlns:wsu="http:
   > //docs.oasis-open.org/wss/2004/01/oasis-200401-'
   >                       +'wss-wssecurity-utility-1.0.xsd"'
   >           +' xmlns:xsd="[4]http://www.w3.org/2001/XMLSchema";'
   >           +'
   xmlns:xsi="[5]http://www.w3.org/2001/XMLSchema-instance";>'
   >           +'<soap:Header>'
   >           +'<wsse:Security soap:mustUnderstand="1" >'
   >           +'<wsse:UsernameToken>'
   >           +'<wsse:Username>PAULRE@ERBINT</wsse:Username>'
   >           +'<wsse:Password
   Type="[6]http://docs.oasis-open.org/wss/2004/01/'
   >         +'oasis-200401-wss-username-token-profile-1.0#'
   >
   +'PasswordText">nor850ton</wsse:Password>'
   >           +'</wsse:UsernameToken>'
   >           +'</wsse:Security>'
   >           +'</soap:Header>';
   >
   >           endsr;
   >
   >
   >
   //---------------------------------------------------------------------
   --*
   >        // assembleSOAPbody;      *
   >
   >
   //---------------------------------------------------------------------
   --*
   >
   >           begsr assembleSOAPbody;
   >
   >           subscriberId    = '3';
   >           transactionIdIn = %trim(lastTransaction);
   >
   >              soapBody =
   >               '<soap:Body>'
   >                 +'<dequeue2>'
   >                    +'<subscriberId>'
   >                       + subscriberId
   >                    +'</subscriberId>'
   >                    +'<transactionIdIn>'
   >                       + transactionIdIn
   >                    +'</transactionIdIn>'
   >                 +'</dequeue2>'
   >              +'</soap:Body>'
   >           +'</soap:Envelope>';
   >
   >           endsr;
   >
   >       /end-free
   >       *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       * Incoming - Scott Klements procedure used to  extract data
   from the
   > XML *
   >       *            response returned from the Web Service. This
   procedure
   > gets *
   >       *            run for each element in the XML.     *
   >
   >
   *----------------------------------------------------------------------
   --*
   >       *
   >      P Incoming        B
   >       *
   >      D Incoming        PI
   >      D   rate                         8F
   >      D   depth                       10I 0 value
   >      D   name                      1024A   varying const
   >      D   path                     24576A   varying const
   >      D   value                             likeds(XmlString_t)
   >      D   attrs                         *   dim(32767)
   >      D                                     const options(*varsize)
   >       *
   >       /free
   >
   >           // This value is not base64 encoded.
   >           // I can't figure out how to get data into this field.
   >           if name = 'count';
   >              p_var = value.data;
   >              count = %dec(%subst(var:1:value.len):5:0);
   >
   >
   >           // This value is base 64 encoded, I can't seem to get this
   to
   > work?
   >           elseif name = 'transactions';
   >              %len(resultVar) = %len(resultVar : *MAX);
   >              decodedLen = base64_decode( value.data
   >                                        : value.len
   >                                        : %addr(resultVar : *data)
   >                                        : %len(resultVar : *MAX) );
   >              %len(resultVar) = decodedLen;
   >
   >           // This value is not base64 encoded - not sure how to
   retrieve
   > it?
   >           // I can't figure out how to get data into this field.
   >           elseif name = 'transactionIdOut';
   >              p_var = value.data;
   >              transactionIdOut = %dec(%subst(var:1:value.len):17:0);
   >
   >           endif;
   >
   >       /end-free
   >       *
   >      P Incoming        E
   >       *
   >
   > The http_url_post_xml executes successfully rc = 1. I get good values
   in
   > the variables count and transactionIdOut without any issue.
   >
   > The data  in field resultVar is supposed to be an XML document,
   however I
   > am having a very tough time doing anything with this data.Ultimately
   what
   > I want to do is parse the data in resultVar and write it into our
   > database.
   >
   >  When I attempt to view the data in variable resultVar (using STRDBG
   from
   > a green screen command line) it is unreadable. It doesn't look like
   an XML
   > document.
   >
   > Next I try and open() a new file in the IFS and write the data to
   this
   > file.
   > fd1 = open('/home/PAULRE/perfDataXML.xml'
   >                       : O_RDWR+O_CREAT+O_TRUNC+O_CCSID
   >                       : 438
   >                       : 1208);
   > callp write(fd1 : %addr(resultVar) : %len(%trim(resultVar)));
   >
   > When I look at this file on the IFS using notepad, it indeed looks
   like an
   > XML file however the first few characters are messed up. Normally an
   XML
   > document starts out like this:
   > <?xml version="1.0" encoding="UTF-8"?>
   > When I look at the document I created (using Notepad) it starts out
   with 2
   > blank spaces and then continues like this:
   > __??xml version="1.0" encoding="UTF-8"?>  It also appears as if the
   > document doesn't have the correct ending. By that I mean that I don't
   > believe this XML is "well formed" (I believe that's the correct
   term). It
   > starts with <tranBlock> however it ends with </tranBl like it was
   > truncated???
   >
   > I've tried many different variations on the open() and the write()
   but I
   > cannot seem to create a document that I can parse. I've read Scott's
   "RPG
   > and the IFS":  I found it very helpful, but I know I don't understand
   all
   > of it.
   >
   > I apologize for asking so many questions but I'm really kind of stuck
   and
   > would appreciate any help. I'm very new to this and I find it very
   > challenging.
   >
   > Also I'm attaching a copy of of perfDataXML that I opened and then
   saved
   > in Notepad.
   >
   >
   > Again...any help would be greatly appreciated, thanks very much and
   have a
   > great day!
   > ___________________________________________________________
   > Paul Reid
   > Application Developer III
   > Erb Group of Companies | 290 Hamilton Road | New Hamburg, Ontario |
   N3A
   > 1A2
   > Phone: 519.662.6133 ext. 2363
   > Web: [7]http://www.erbgroup.com/
   >
   >
   >
   > From:   Scott Klement <sk@xxxxxxxxxxxxxxxx>
   > To:     HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
   > Date:   12/16/2013 09:51 PM
   > Subject:        Re: Advice on how to process xsd:base64Binary XML
   element
   > retrieved       from a web service.
   > Sent by:        ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   >
   >
   >
   > Hello Paul,
   >
   > 1) Sorry about the data type... should've been A=alphanumeric.   I
   > must've forgotten that.
   >
   > 2) I have no way of knowing what the data is or how you plan to use
   it,
   > so I'm not really sure how to help you here.  You say it's XML --
   okay,
   > so what do you want to do with the XML?  If the goal is to parse it,
   > then either save it into a variable, and pass that into an XML
   parser,
   > or save it to a file (which would be much easier if the data isn't
   > already EBCDIC -- though, that'd also run slightly slower.)
   >
   > 3) To get this from the pointer, you need a based variable and you
   need
   > to use %SUBST.
   >
   > D var             s             50a   based(p_var)
   > D count           s              9p 0
   > D transactionId   s             15p 0
   >
   >   /free
   >        .
   >        .
   >        if name = 'count';
   >          p_var = value.data;
   >          count = %dec( %subst(var:1:value.len): 9 : 0 );
   >        elseif name = 'transactionIdOut';
   >          p_var = value.data;
   >          transactionId = %dec( %subst(var:1:value.len) : 15 : 0 );
   >        .
   >        .
   >
   > Note: All of this is off the top of my head and untested.  It's
   expected
   > that you will be able to troubleshoot/fix any problems with it.
   >
   >
   >
   > On 12/16/2013 3:32 PM, PReid@xxxxxxxxxxxx wrote:
   > >     Hello again.
   > >     I feel like I'm getting closer with this, but I'm still not
   there.
   > Just
   > >     to refresh your memory the Response XML that I get back looks
   like
   > >     this:
   > >      <soapenv:Body>
   > >       <dequeue2Response>
   > >          <dequeue2Return>
   > >             <count>6</count>
   > >
   > >
   <transactions>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz...=</transactions>
   > >              <transactionIdOut>58744654</transactionIdOut>
   > >          </dequeue2Return>
   > >       </dequeue2Response>
   > >     </soapenv:Body>
   > >     I implemented the code that Scott recommended into my program,
   and I
   > >     think it is working, I just have a few questions.
   > >     #1. I could not define the "resultVar" variable as it was shown
   > below
   > >     (without a Variable Type). I kept getting the following errors:
   > >      NF3391E The LEN keyword is valid only for Data Structures, or
   for
   > type
   > >     A, C, or G; keyword is ignored.
   > >      RNF3365E Keyword VARYING is allowed only for an item defined
   as
   > >     character, graphic, or UCS-2.
   > >      RNF3438E LIKE keyword is expected for field RESULTVAR but not
   > found;
   > >     definition is ignored.
   > >     I defined it as Variable Type "C" which i believe means
   UCS-2...but
   > I'm
   > >     not sure if this is correct. It might depend on question #2
   below.
   > >
   > >     #2. The "transactions" element is base64 encoded and I believe
   that
   > the
   > >     example code that Scott showed me is in fact decoding it...I am
   just
   > at
   > >     a loss as to what to do with it. The data that is encoded in
   the
   > >     element, is itself,  an XML document. I am thinking that I
   should
   > write
   > >     this out to a temporary file on the IFS and then parse it later
   in
   > the
   > >     program?,..but I don't know how to output an XML to the
   IFS?...I'm
   > also
   > >     not sure if this is the best way to handle this situation...In
   the
   > end
   > >     I want to write this data into files on our IBMi.
   > >
   > >     #3. The "count" and "transactionIdOut" elements are not base64
   > encoded,
   > >     however; I do need the data returned in these fields. With the
   > changes
   > >     that I've made to my "Incoming" procedure, I can't seem to
   retrieve
   > the
   > >     data stored in the "value" field. How do I get these values out
   of
   > the
   > >     new "value" data structure?
   > >     Below I am including...what I think...is the relevant portions
   of
   > code
   > >     from my program. I can supply the entire program if you want.
   > >     *
   > >
   *----------------------------------------------------------------------
   > >     --*
   > >     *
   > >     D Incoming        PR
   > >     D   rate                         8F
   > >     D   depth                       10I 0 value
   > >     D   name                      1024A   varying const
   > >     D   path                     24576A   varying const
   > >     D   value                             likeds(Xmlstring_t)
   > >     D   attrs                         *   dim(32767)
   > >     D                                     const options(*varsize)
   > >     *
   > >     * Log.
   > >     D dequeue2...
   > >     D                 S           1000A   varying
   > >     *
   > >     * Can't figure out how to get the data into these fields.
   > >     D count...
   > >     D                 S              5P 0 inz(*zeros)
   > >     D transactionIdOut...
   > >     D                 S             17P 0 inz(*zeros)
   > >     *
   > >     * Not sure if resultVar is defined correctly?
   > >     D resultVar       S               C    len(2000000) varying
   > >     D decodedLen      S             10I 0
   > >     *
   > >
   *----------------------------------------------------------------------
   > >     --*
   > >     *
   > >     // Write out a Log.
   > >        dequeue2 = '/home/PAULRE/dequeue2.txt';
   > >        http_debug(*ON : dequeue2);
   > >     // Change the way the XML parser returns the data.
   > >     // We need to use pointer since it is so large...
   > >        http_XmlReturnPtr(*on);
   > >     // Post.
   > >        rc = http_url_post_xml(
   > > 'https://www.myshawtracking.ca:443/otsWebWS/services/OTSWebSvcs'
   > >           : %addr(SOAP) + 2
   > >           : %len(SOAP)
   > >           : *NULL
   > >           : %paddr(Incoming)
   > >           : %addr(rate)
   > >           : HTTP_TIMEOUT
   > >           : HTTP_USERAGENT
   > >           : 'text/xml'
   > >           : 'http://www.qualcomm.com/dequeue2');
   > >     // Success!!!
   > >        if rc = 1;
   > >     *
   > >
   *----------------------------------------------------------------------
   > >     --*
   > >     *
   > >     P Incoming        B
   > >     *
   > >     D Incoming        PI
   > >     D   rate                         8F
   > >     D   depth                       10I 0 value
   > >     D   name                      1024A   varying const
   > >     D   path                     24576A   varying const
   > >     D   value                             likeds(XmlString_t)
   > >     D   attrs                         *   dim(32767)
   > >     D                                     const options(*varsize)
   > >     *
   > >     /free
   > >         // This value is not base64 encoded.
   > >         // I can't figure out how to get data into this field.
   > >         if name = 'count';
   > >            // count = %dec(value:5:0);
   > >         // This value is base 64 encoded, I think this is working,
   and
   > the
   > >     data is
   > >         // in resultVar...now what do I do with it?
   > >         elseif name = 'transactions';
   > >            %len(resultVar) = %len(resultVar : *MAX);
   > >            decodedLen = base64_decode( value.data
   > >                                      : value.len
   > >                                      : %addr(resultVar : *data)
   > >                                      : %len(resultVar : *MAX) );
   > >            %len(resultVar) = decodedLen;
   > >         // This value is not base64 encoded - not sure how to
   retrieve
   > it?
   > >         // I can't figure out how to get data into this field.
   > >         elseif name = 'transactionIdOut';
   > >            // transactionIdOut = %dec(value:17:0);
   > >         endif;
   > >     /end-free
   > >     *
   > >     P Incoming        E
   > >     Thanks very much for your time. If there is any more
   information you
   > >     need, just let me know.
   > >     Have a great day!
   > >     ___________________________________________________________
   > >     Paul Reid
   > >     Application Developer III
   > >     Erb Group of Companies | 290 Hamilton Road | New Hamburg,
   Ontario |
   > N3A
   > >     1A2
   > >     Phone: 519.662.6133 ext. 2363
   > >     Web: [1][8]http://www.erbgroup.com/
   > >     From:        Scott Klement <sk@xxxxxxxxxxxxxxxx>
   > >     To:        HTTPAPI and FTPAPI Projects
   > <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
   > >     Date:        12/13/2013 12:56 AM
   > >     Subject:        Re: Advice on how to process xsd:base64Binary
   XML
   > >     element retrieved        from a web service.
   > >     Sent by:        ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   > >
   __________________________________________________________________
   > >
   > >     hi Paul,
   > >     HTTPAPI was originally written for OS/400 V4R2, and therefore
   does
   > not
   > >     "directly" support variables longer than 65535 characters long.
   > >     However,
   > >     in many cases HTTPAPI does have pointer-based interfaces that
   allow
   > >     data
   > >     as large as 16 MB to be returned -- so in order to handle data
   "up
   > to
   > >     approx 1 MB" you will want to use the pointer-based interfaces.
    You
   > >     can
   > >     use them in conjunction with V7R1's support for large
   variables.
   > >     Steps:
   > >     1) Before calling http_url_post_xml(), you should call
   > >     http_XmlReturnPtr(*ON).  What this does is change the way the
   XML
   > >     parser
   > >     returns data.  Instead of returning as a 65535 character
   string, it
   > >     will
   > >     now return it as a data structure, that has subfield for a
   pointer,
   > and
   > >     a subfield with a 10i 0 integer containing the length of the
   string
   > in
   > >     bytes.
   > >     D XmlString_t     ds                  qualified Template
   > >     D   Data                          *
   > >     D   Len                         10i 0
   > >     2) Change your 'Incoming' procedure (NOTE: you can call this
   > procedure
   > >     whatever you like, it does not have to be 'Incoming', that was
   just
   > a
   > >     name I used as an example) to receive this data structure in
   place
   > of
   > >     the 'value' string.
   > >     D Incoming        PR
   > >     D   rate 8F
   > >     D   depth                       10I 0 value
   > >     D   name                      1024A   varying const
   > >     D   path                     24576A   varying const
   > >     D   value likeds(XmlString_t)
   > >     D   attrs                         * dim(32767)
   > >     D                                     const options(*varsize)
   > >     3) Now that 'value' is coming in as a pointer, it can be as
   large as
   > >     you
   > >     want.  You can now pass the 'value' parameter to tbe
   base64_decode
   > >     procedure to eliminate the base64 encoding. Personally I like
   to use
   > a
   > >     VARYING variable for this sort of thing, and there's a trick to
   > working
   > >     with VARYING as a pointer...   you need to set it's length to
   the
   > >     maximum length first, then pass the address of only the data
   > portion,
   > >     then set it's length back to the returned length.
   > >     D resultVar       s                   len(2000000) varying
   > >          %len(resultVar) = %len(resultVar: *MAX);
   > >          decodedlen = base64_decode( value.data
   > >                                    : value.len
   > >                                    : %addr(resultVar: *data)
   > >                                    : %len(ResultVar: *MAX) );
   > >          %len(resultVar) = decodedlen;
   > >     4) Now you have the decoded data in 'resultVar'.  However, you
   > should
   > >     know that this data will have the exact same binary value that
   it
   > had
   > >     when it was encoded.  If your data is text and the sender had
   it
   > >     encoded
   > >     in ASCII (or Unicode), then your data in resultVar will in
   ASCII, so
   > >     you'll probably want to translate it to EBCDIC next.
   > >     If the data in resultVar is not text, like an image, PDF, Word
   > >     Document,
   > >     sound file, etc...  then you won't want to translate it to
   EBCDIC,
   > as
   > >     that would corrupt the data.  (That is what is meant by
   'binary')
   > >     5) Not sure what you want to do next, it'll depend on the
   purpose of
   > >     this data.  Should it be written to the IFS?  Stored in a BLOB?
    So
   > >     I'll
   > >     leave that part as an exercise for you.
   > >     Good luck....
   > >     On 12/12/2013 9:48 AM, PReid@xxxxxxxxxxxx wrote:
   > >     >     Hello everyone. I am not very experienced with Web
   Services so
   > >     bear
   > >     >     with me. I did a fair bit of research on the various
   forums
   > >     before
   > >     >     posting, but I failed to find a good example of what I am
   > looking
   > >     for.
   > >     >     I'm hoping that someone can help, possibly with an
   example.
   > >     >     I am predominately an RPG programmer. We are running an
   IBM
   > Power
   > >     7 at
   > >     >     V7R1, and I have Scott's HTTPAPI V1.24 downloaded and
   > installed.
   > >     I am
   > >     >     using HTTPAPI to consume another Web Service and it works
   > >     beautifully.
   > >     >     My latest challenge it that I have consume a Web Service
   that
   > >     includes
   > >     >     an element in the XML response that is data type
   > xsd:base64Binary
   > >     and
   > >     >     I'm not really sure how to do it. The WSDL for this web
   > service
   > >     is:
   > >     >
   > >     [1][2]
   > [9]https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/O
   > >     TSW
   > >     >     ebSvcs.wsdl
   > >     >     The WIKI for this Web Service is:
   > >     >
   > >     [2][3]
   > [10]https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+De
   > >     que
   > >     >     ue
   > >     >     The method that I must consume is named DEQUEUE2.
   > >     >     I have created an RPG program that POSTS a request to the
   Web
   > >     Service
   > >     >     using the following HTTPAPI subprocedure:
   > >     >        rc = http_url_post_xml(
   > >     >
   > >     >
   'https://www.myshawtracking.ca:443/otsWebWS/services/OTSWebSvcs'
   > >     >                  : %addr(SOAP) + 2
   > >     >                  : %len(SOAP)
   > >     >                  : *NULL
   > >     >                  : %paddr(Incoming)
   > >     >                  : %addr(rate)
   > >     >                  : HTTP_TIMEOUT
   > >     >                  : HTTP_USERAGENT
   > >     >                  : 'text/xml'
   > >     >                  : 'http://www.qualcomm.com/dequeue2');
   > >     >     I am receiving rc = 1 which I believe means that I am
   > >     successfully
   > >     >     receiving an XML response. FYI - The procedure "Incoming"
   was
   > >     copied
   > >     >     from Scott's EXAMPLE11.
   > >     >     The response XML is as follows.
   > >     >     <soapenv:Body>
   > >     >     <dequeue2Response>
   > >     >     <dequeue2Return>
   > >     >     <count>6</count>
   > >     >     <transactionIdOut>58744654</transactionIdOut>
   > >     >     (transactions>
   > >     >
   PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48dHJjaz4=
   > >     >     </transactions>
   > >     >     </dequeue2Return>
   > >     >     </dequeue2Response>
   > >     >     </soapenv:Body>
   > >     >     The "transactions" element is xsd:base64Binary and I
   don't
   > know
   > >     how to
   > >     >     decode it. I have downloaded Scott's BASE64R4 service
   program
   > and
   > >     I
   > >     >     suspect I'd use procedure BASE64_DECODE, but I'm not sure
   how
   > I
   > >     would
   > >     >     employ it in this situation. Also...according to the wiki
   the
   > >     >     "transactions" element could be as large as
   "Approximately
   > 1mb"
   > >     >     although I'm not really sure what they mean by
   approximately??
   > >     >     The "count" and "transactionIdOut" and not encoded and I
   need
   > the
   > >     data
   > >     >     in them in addition to the encoded data.
   > >     >     I understand that I may not even be using the correct
   post
   > >     procedure
   > >     >     (remember I'm not that experienced) and in the interim I
   am
   > going
   > >     to
   > >     >     try some of Scott's other procedures.
   > >     >     Any help or examples on how to get this data would be
   much
   > >     appreciated.
   > >     >     Thanks!
   > >     >
   ___________________________________________________________
   > >     >     Paul Reid
   > >     >     Application Developer III
   > >     >     Erb Group of Companies | 290 Hamilton Road | New Hamburg,
   > Ontario
   > >     | N3A
   > >     >     1A2
   > >     >     Phone: 519.662.6133 ext. 2363
   > >     >     Web: [3][4][11]http://www.erbgroup.com/
   > >     >
   > >     > References
   > >     >
   > >     >     1.
   > >     [5]
   >
   [12]https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/OTS
   W
   > >     ebSvcs.wsdl
   > >     >     2.
   > >     [6]
   >
   [13]https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Dequ
   e
   > >     ue
   > >     >     3. [7][14]http://www.erbgroup.com/
   > >     >
   > >     >
   > >     >
   > >     >
   > >
   -----------------------------------------------------------------------
   > >     > This is the FTPAPI mailing list.  To unsubscribe, please go
   to:
   > >     > [8][15]http://www.scottklement.com/mailman/listinfo/ftpapi
   > >     >
   > >
   -----------------------------------------------------------------------
   > >
   -----------------------------------------------------------------------
   > >     This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > >     [9][16]http://www.scottklement.com/mailman/listinfo/ftpapi
   > >
   -----------------------------------------------------------------------
   > >
   > > References
   > >
   > >     1. [17]http://www.erbgroup.com/
   > >     2.
   >
   [18]https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/OTS
   W
   > >     3.
   >
   [19]https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Dequ
   e
   > >     4. [20]http://www.erbgroup.com/
   > >     5.
   > [21]https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/
   > OTSWebSvcs.wsdl
   >
   > >     6.
   >
   [22]https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Dequ
   eue
   > >     7. [23]http://www.erbgroup.com/
   > >     8. [24]http://www.scottklement.com/mailman/listinfo/ftpapi
   > >     9. [25]http://www.scottklement.com/mailman/listinfo/ftpapi
   > >
   > >
   > >
   > >
   -----------------------------------------------------------------------
   > > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > > [26]http://www.scottklement.com/mailman/listinfo/ftpapi
   > >
   -----------------------------------------------------------------------
   >
   >
   -----------------------------------------------------------------------
   > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > [27]http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   -----------------------------------------------------------------------
   >
   > [Anhang "perfDataXML.xml" gelöscht von Thomas Raddatz/OBI/DE]
   >
   -----------------------------------------------------------------------
   > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > [28]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.

References

   1. https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/
   2. http://schemas.xmlsoap.org/soap/envelope/
   3. http://schemas.xmlsoap.org/ws/2004/03/addressing
   4. http://www.w3.org/2001/XMLSchema
   5. http://www.w3.org/2001/XMLSchema-instance
   6. http://docs.oasis-open.org/wss/2004/01/'
   7. http://www.erbgroup.com/
   8. http://www.erbgroup.com/
   9. https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/O
  10. https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+De
  11. http://www.erbgroup.com/
  12. https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/OTSW
  13. https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Deque
  14. http://www.erbgroup.com/
  15. http://www.scottklement.com/mailman/listinfo/ftpapi
  16. http://www.scottklement.com/mailman/listinfo/ftpapi
  17. http://www.erbgroup.com/
  18. https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/OTSW
  19. https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Deque
  20. http://www.erbgroup.com/
  21. https://www.myshawtracking.ca/otsWebWS/services/OTSWebSvcs/wsdl/
  22. https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Dequeue
  23. http://www.erbgroup.com/
  24. http://www.scottklement.com/mailman/listinfo/ftpapi
  25. http://www.scottklement.com/mailman/listinfo/ftpapi
  26. http://www.scottklement.com/mailman/listinfo/ftpapi
  27. http://www.scottklement.com/mailman/listinfo/ftpapi
  28. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------