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

Re: New to XML - Dequeue2 Request Issue



   Corby,


   If the size of outbuf is too small to take the complete result, I would
   try to decode the Base64 data chunk by chunk. The key is to pass an
   input buffer that is a multiple of 4 to base64_decode(), hence
   inChunkSize = 20000. Theoretically the size of the output buffer
   (outbuf) can been 33% smaller than inChunkSize, due to the nature of
   the Base64 encoding. (Wikipedia "base64": The ratio of output bytes to
   input bytes is 4:3 (33% overhead)).


   I did not compile nor test the example code, but at least it should
   demonstrate the idea.


   Thomas.


      D offset          S             10I 0

      D inChunkSize     S             10I 0 inz(20000)

      D outbuf          S          24576A

      D outlen          S             10I 0


            // ------------------------------------------

            //   create new stream file in IFS

            //   tag it with CCSID 1208 (UTF-8)

            // ------------------------------------------


            http_XmlReturnPtr(*On);


            if name = 'transactions';

              unlink(embfile);

              fd = open(embfile: O_CREAT + O_CCSID + O_WRONLY

                        : S_IRUSR + S_IWUSR

                        : 819);


              offset = 0;

              dow (offset < value.len);

                if (inChunkSize > value.len - offset);

                  inChunkSize = value.len - offset;

                endif;

                outlen = base64_decode(value.buf + offset

                                       : inChunkSize

                                       : %addr(outbuf)

                                       : %size(outbuf) );

                callp write(fd: %addr(outbuf): outlen);

                offset = offset + outlen;

              enddo;


              callp close(fd);

            endif;

       /end-free

      P                 E



   -----Ursprüngliche Nachricht-----
   Von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] Im Auftrag von Julius
   Kaj
   Gesendet: Dienstag, 26. Januar 2016 19:13
   An: 'HTTPAPI and FTPAPI Projects'
   Betreff: SV: New to XML - Dequeue2 Request Issue


   Ahh... Don't know. But a few thoughts:


   Is the length of the outbuf variable too short (24576 bytes) to hold
   all the decoded data? That would truncate the data, but the decoding
   routine would still return the full length of the decoded data.

   If base64_decode() returns a length that is longer than the provided
   outbuffer, then the write to the file will include "garbage", i.e.
   random bytes from beyound the limit of the provided outbuffer is
   written to the file.


   Why do you open your embfile with codepage 817, yet you state in your
   comments that it should be "tagged" as codepage 1208 (UTF-8)?




   -----Oprindelig meddelelse-----

   Fra: [1]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [[2]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] På vegne af
   [3]corby.weaver@xxxxxxxxxxxxxxxxx

   Sendt: 26. januar 2016 16:55

   Til: HTTPAPI and FTPAPI Projects

   Emne: RE: New to XML - Dequeue2 Request Issue


      I resolved part of my decoding issue.  It was a case of too many

      versions of my own code.  However, I'm still running into an issue.
   My

      file contains vehicle position information for our trucks.  The file
   is

      rather large.  The full file comes in fine.  When I go to decode, It

      gives me the first 180 or so lines fine.  After that, jumbled
   garbage.

       I'm bringing my encoded xml file into an ifs file.  I need to
   decode

      what is inside of the "transactions" tags.  My code is as follows:

      D Element_Val_t   ds                  qualified


      D                                     based(template)


      D   buf                           *


      D   len                         10i 0




         // ----------------------------------------------

         //  Parse the SOAP document (the one in soapfile)

         //  Inside it will be another XML document that's

         //  embedded within -- save that to a separate

         //  file in the IFS.

         // ----------------------------------------------


           embfile = '/tmp/OmniTracsFuelFin.soap';


           if (http_parse_xml_stmf( soapfile

                                  : HTTP_XML_CALC

                                  : *null

                                  : %paddr(SaveEmbed)

                                  : %addr(embfile) ) < 0);

               http_crash();

           endif;

        *inlr = *on;


         // ----------------------------------------------



      P SaveEmbed       B


      D SaveEmbed       PI


      D   embfile                     50a   varying


      D   depth                       10I 0 value


      D   name                      1024A   varying const


      D   path                     24576A   varying const


      D   value                             likeds(Element_Val_t)


      D   attrs                         *   dim(32767)


      D                                     const options(*varsize)




      D writeConst      PR            10I 0 ExtProc('write')


      D  fildes                       10i 0 value


      D  buf                       65535A   const options(*varsize)


      D  bytes                        10U 0 value




      D xmlhdr          s             80a   varying


      D fd              s             10i 0




      D outbuf          S          24576A


      D outlen          S             10I 0




            // ------------------------------------------


            //   create new stream file in IFS


            //   tag it with CCSID 1208 (UTF-8)


            // ------------------------------------------




        http_XmlReturnPtr(*On);




            if name = 'transactions';


            unlink(embfile);


            fd = open(embfile: O_CREAT + O_CCSID + O_WRONLY

                          : S_IRUSR + S_IWUSR

                          : 819);



            outlen = base64_decode( value.buf

                      : value.len

                      : %addr(outbuf)

                      : %size(outbuf) );


            callp write(fd: %addr(outbuf): outlen);


            callp close(fd);

            endif;

       /end-free

      P                 E

      Corby Weaver

      From:        Paul Reid <[4]PReid@xxxxxxxxxxxx>

      To:        HTTPAPI and FTPAPI Projects
   <[5]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>,

      Date:        01/21/2016 10:12 AM

      Subject:        RE: New to XML - Dequeue2 Request Issue

      Sent by:        [6]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

        __________________________________________________________________


      Hello again Corby.

      If you look in the example program that I posted previously, called

      DSRPERFMON, you should see a data area named ##PERFMON. This data
   area

      contains the Last Transaction that was received and saved from the

      previous run. If you include this Last Transaction in your next
   request

      you only receive data that is greater than this Last Transaction. At

      the end of each run I store the Last Transaction in the data area

      ##PERFMON and so on...This way I only get "new" data that I haven't
   yet

      received that I can append to my database file on our backend
   system. I

      believe this is doing what you are asking.

      As far as I know, with this service,  there is no way to select data

      via a date/time stamp range. I believe you have to use this
   Transaction

      number.

      I hope this helps.


   -----------------------------------------------------------------------

      -------------------------------

      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][7]http://www.erbgroup.com/

      -----Original Message-----

      From: [8]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

      [[2][9]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of

      [10]corby.weaver@xxxxxxxxxxxxxxxxx

      Sent: Thursday, January 21, 2016 10:20 AM

      To: HTTPAPI and FTPAPI Projects

      Subject: Re: New to XML - Dequeue2 Request Issue

        I've gotten some good data with my Dequeue2 requests.  Thanks for

        everyone's help.

        Can I select by date/time stamp which records I pull prior to the

        decoding process?  I only want to pull information since the
   previous

        request.


   -----------------------------------------------------------------------

      This is the FTPAPI mailing list.  To unsubscribe, please go to:

      [3][11]http://www.scottklement.com/mailman/listinfo/ftpapi


   -----------------------------------------------------------------------


   -----------------------------------------------------------------------

      This is the FTPAPI mailing list.  To unsubscribe, please go to:

      [4][12]http://www.scottklement.com/mailman/listinfo/ftpapi


   -----------------------------------------------------------------------


   References


      1. [13]http://www.erbgroup.com/

      2. [14]mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

      3. [15]http://www.scottklement.com/mailman/listinfo/ftpapi

      4. [16]http://www.scottklement.com/mailman/listinfo/ftpapi

   -----------------------------------------------------------------------

   This is the FTPAPI mailing list.  To unsubscribe, please go to:

   [17]http://www.scottklement.com/mailman/listinfo/ftpapi

   -----------------------------------------------------------------------


   ______________________________________________________________________

   This email has been scanned by the Symantec Email Security.cloud
   service.

   For more information please visit [18]http://www.symanteccloud.com
   ______________________________________________________________________


   ______________________________________________________________________

   This email has been scanned by the Symantec Email Security.cloud
   service.

   For more information please visit [19]http://www.symanteccloud.com
   ______________________________________________________________________

   -----------------------------------------------------------------------

   This is the FTPAPI mailing list.  To unsubscribe, please go to:

   [20]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. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   2. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   3. mailto:corby.weaver@xxxxxxxxxxxxxxxxx
   4. mailto:PReid@xxxxxxxxxxxx
   5. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
   6. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   7. http://www.erbgroup.com/
   8. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   9. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  10. mailto:corby.weaver@xxxxxxxxxxxxxxxxx
  11. http://www.scottklement.com/mailman/listinfo/ftpapi
  12. http://www.scottklement.com/mailman/listinfo/ftpapi
  13. http://www.erbgroup.com/
  14. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  15. http://www.scottklement.com/mailman/listinfo/ftpapi
  16. http://www.scottklement.com/mailman/listinfo/ftpapi
  17. http://www.scottklement.com/mailman/listinfo/ftpapi
  18. http://www.symanteccloud.com/
  19. http://www.symanteccloud.com/
  20. 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
-----------------------------------------------------------------------