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

Re: Ftpapi Digest, Vol 41, Issue 36



   Hi Scott.
   Thanks for your interest in my problems.
   Here is my test program that gives garbage in "value":
   H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')

    /copy httpapi_h
    /copy ifsio_h


   D Element_Val_t   ds                  qualified
   D                                     based(Template)
   D    buf                          *
   D    len                        10i 0

   D GetInnerDoc     PR
   D   filename                    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 Incoming        PR
   D   userdata                      *   value
   D   depth                       10I 0 value
   D   name                      1024A   varying const
   D   path                     24576A   varying const
   D   value                    65535A   varying const
   D   attrs                         *   dim(32767)
   D                                     const options(*varsize)

   D SOAP            s          32767A   varying
   D rc              s             10I 0
   D rate            s              8F
   D Result          s             12P 2
   D Filename        s             50a   varying

    /free

     http_debug(*ON);
     http_xmlReturnPtr(*ON);
       filename = http_tempfile() + '.xml';
     //filename = '/tmp/SKY_tempMan.xml';

     http_XmlStripCRLF(*ON);

     SOAP =
      '<?xml version="1.0" encoding="utf-8"?>'
     +'<SOAP:Envelope'
     +'    xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/";'
     +'    xmlns:tns="http://80.69.86.148/test/sync/SkynetSync.exe/";>'
     +'<SOAP:Body>'
     +'  <tns:DownloadData>'
     +'      <tns:aDocType>Summarymanifest</tns:aDocType>'
     +'      <tns:aSessionId>'
     +           '871704F6E9E0AE3667AE7B02C91AFA78D471</tns:aSessionId>'
     +'  </tns:DownloadData>'
     +'</SOAP:Body>'
     +'</SOAP:Envelope>';

     http_debug(*ON);

     rc = http_url_post_xml(
                'http://80.69.86.148/test/sync/SkynetSync.exe/'
                        +'soap/ISkynetSynchroniser'
                       : %addr(SOAP) + 2
                       : %len(SOAP)
                       : *NULL
                       : %paddr(GetInnerDoc)
                       : %addr(filename)
                       : HTTP_TIMEOUT
                       : HTTP_USERAGENT
                       : 'text/xml'
                       : 'urn:SkynetSynchroniserIntf-ISkynetSynchroniser'
                        +'#DownloadData');
     if (rc <> 1);
        http_crash();
     else;
      rc = http_parse_xml_stmf( filename
                             : HTTP_XML_CALC
                             : *null
                             : %paddr(Incoming)
                             : *null );
     if (rc <> 1);
        http_crash();
         endif;
     endif;

     *inlr = *on;

    /end-free


    *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    * GetInnerDoc():  End-element handler for HTTPAPI's XML parser.
    *                 to be called by http_url_post_xml()
    *                           or by http_parse_xml_stmf()
    *
    *                 The response from the web service contains
    *                 an "inner" XML document.  This retrieves
    *                 that document and writes it to a temporary
    *                 file in th IFS.
    *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   P GetInnerDoc     B                   export
   D GetInnerDoc     PI
   D   filename                    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 fd              s             10i 0

    /free
       if name = 'return';
           fd = open( filename
                    : O_CREAT + O_TRUNC + O_WRONLY + O_CCSID
                      + O_TEXTDATA + O_TEXT_CREAT
                    : S_IRUSR + S_IWUSR
                    : 819
                    : 0 );
           // FIXME: Add error handling.
           callp write(fd: value.buf: value.len);
           callp close(fd);
       endif;
    /end-free
   P                 E

   P Incoming        B
   D Incoming        PI
   D   userdata                      *   value
   D   depth                       10I 0 value
   D   name                      1024A   varying const
   D   path                     24576A   varying const
   D   value                    65535A   varying const
   D   attrs                         *   dim(32767)
   D                                     const options(*varsize)

   D   M_Pref        s             50a   varying
   D   M_Number      s             50a   varying
   D   M_Date        s             50a   varying

    /free
          select;
          when name = 'MastermanifestPrefix';
             M_Pref    = value;
          when name = 'MastermanifestNumber';
             M_Number  = value;
          when name = 'DateofManifest';
             M_Date    = value;
       // etc...
          endsl;
    /end-free
   P                 E
   A debug of value at the M_Pref  line gives me this:
   VALUE =

             ....5...10...15...20...25...30...35...40...45...50...55...60
        1   '      Z%$ã\                                            '
       61   '  @       ÛÊÃæ                                        '
      121   '                    ENDELEMENT        @       ÛÊÃæ      '
      181   '    *N
   '
   note -
   the session ID :
   871704F6E9E0AE3667AE7B02C91AFA78D471
   is  hard coded in my test program
   It exprires after 24 hours..
   If a new session ID is needed I (so far)  use this stand alone test
   program that writes a new session Id to an IFS file:
   H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')


    /copy httpapi_h

   D Incoming        PR
   D   rate                         8F
   D   depth                       10I 0 value
   D   name                      1024A   varying const
   D   path                     24576A   varying const
   D   value                    65535A   varying const
   D   attrs                         *   dim(32767)
   D                                     const options(*varsize)

   D SOAP            s          32767A   varying
   D rc              s             10I 0
   D rate            s              8F
   D Result          s             12P 2

    /free
     http_XmlStripCRLF(*ON);

     SOAP =
      '<?xml version="1.0" encoding="utf-8"?>'
     +'<SOAP:Envelope'
     +'    xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/";'
     +'    xmlns:tns="http://80.69.86.148/test/sync/SkynetSync.exe/";>'
     +'<SOAP:Body>'
     +'  <tns:Login>'
     +'      <tns:aStationId>SYS</tns:aStationId>'
     +'      <tns:aUserName>SYS</tns:aUserName>'
     +'      <tns:aPassword>SYS</tns:aPassword>'
     +'  </tns:Login>'
     +'</SOAP:Body>'
     +'</SOAP:Envelope>';



     rc = http_url_post(

                'http://80.69.86.148/test/sync/SkynetSync.exe/'
                        +'soap/ISkynetSynchroniser'
                       : %addr(SOAP) + 2

                       : %len(SOAP)
                       : '/tmp/SkyLogin.xml'

                       : HTTP_TIMEOUT
                       : HTTP_USERAGENT
                       : 'text/xml'
                       : 'urn:SkynetSynchroniserIntf-ISkynetSynchroniser'
                        +'#Login');
     if (rc <> 1);

        http_crash();
     else;

      // xxx

     endif;


     *inlr = *on;


    /end-free


   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                    65535A   varying const
   D   attrs                         *   dim(32767)
   D                                     const options(*varsize)

   D atof            PR             8F   extproc('atof')
   D   string                        *   value options(*string)

    /free
        if (name = 'ConversionRateResult');
           rate = atof(value);
        endif;
    /end-free
   P                 E
   Med vennlig hilsen / Best regards
   Jan Ottar Valderhaug
   SYSTEMA AS
   St.Halvardsgt. 33A , 0192 Oslo
   Tel: +47 22660660   Direct: +47 22660654   Mob: +47 48052470   Fax:
   +47 22660661
   ----- Message from Scott Klement <sk@xxxxxxxxxxxxxxxx> on Tue, 24 Nov
   2009 11:47:42 -0600 -----

                                                                      To:

   HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

                                                                 Subject:

   Re: Using %paddr(GetInnerDoc) in http_url_post_xml and thereafter
   http_parse_xml_stmf

   Hello,
   I've done many projects like this, and haven't had problems with
   garbage
   in the values.  Can you please put together a simple program (the
   simplest possible program) that reproduces the problem and upload it
   here?
   It should be a program that I can copy/paste into RDi and run compile
   and run.
   If I can reproduce the problem, I should (hopefully) be able to fix
   it.
   janottar@xxxxxxxxxx wrote:
   >    NOW the project is brought to life again and I'm struggeling to
   >    remember / find the code I started to make in april..
   ----- Message from Scott Klement <sk@xxxxxxxxxxxxxxxx> on Tue, 24 Nov
   2009 11:50:45 -0600 -----

                                                                      To:

   HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

                                                                 Subject:

   Re: Problems with Exmaple18, any help is usefully..

   Hello Mario,
   You either have a routing problem, or (probably more likely) you have
   a
   firewall blocking your access to the web.
   You are not experiencing a DNS problem (the error you posted is not
   related to DNS) so posting your DNS configuration didn't help.  The
   problem is that HTTPAPI sends a connection request to the server it's
   trying to connect to, and it gets no response.  That means that
   there's
   a packet filtering firewall that's discarding the connection attempt.
   (Or, less likely, that a router misconfiguration is causing the
   packets
   to be dropped.)
   Mario Rodrigues wrote:
   >    Hi, everybody
   >
   >
   >    I install HTTPAPI tool and after that, run an EXAMPLE18 on my
   iSeries
   >    and I have a response like this:
   >
   >
   >    Selection or command
   >
   >     ===> CALL PGM(EXAMPLE18) PARM('USD' 'JPY' 12.00)
   >
   >
   >     F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel
   >
   >     Timeout occurred while trying to connect to server!
   >
   >
   >    -  So, I consult this forum obtain an answer for my problem.
   >
   > -  I found this subject apparently like mine "RE: Cant ping address
   from 400
   > to use Httpapi example18 and example19." ,  but my iSeries TCP
   configuration
   > is like:
   >
   >                         Change TCP/IP Domain
   > (CHGTCPDMN)
   >
   >  Type choices, press
   > Enter.
   >
   > Host name  . . . . . . . . . . .   'AS400'
   >
   > Domain name  . . . . . . . . . .
   > 'APPN.SNA.IBM.COM'
   >
   > Domain search list . . . . . . .
   > *DFT
   >
   > Host name search priority  . . .   *LOCAL        *REMOTE, *LOCAL,
   > *SAME
   >
   >  Domain name
   > server:
   >
   >    Internet address . . . . . . .
   > '123.45.6.7'
   >
   >
   > '123.45.6.8'
   >
   >
   > Bottom
   >
   >  F3=Exit   F4=Prompt   F5=Refresh   F10=Additional parameters
   > F12=Cancel
   >
   >  F13=How to use this display        F24=More
   > keys
   >
   >
   >   Change TCP/IP Domain (CHGTCPDMN)
   >
   >
   >
   >
   >  Type choices, press
   > Enter.
   >
   >                                    Additional
   > Parameters
   >
   >
   >
   >
   >  Port . . . . . . . . . . . . . .   53            1-65535,
   > *SAME
   >
   >  Protocol . . . . . . . . . . . .   *UDP          *UDP, *TCP,
   > *SAME
   >
   >  Initial domain name server . . .   *FIRST        *FIRST, *ROTATE,
   > *SAME
   >
   >  Domain name server
   > retry:
   >
   >    Number of retries  . . . . . .   2             1-99,
   > *SAME
   >
   >    Time interval  . . . . . . . .   2             1-99,
   > *SAME
   >
   >
   >
   >
   >
   > Bottom
   >
   >  F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this
   > display
   >
   >  F24=More
   > keys

   >
   >   - And the file that I have in ( IFS/.../tmp/httpapi_debug.txt )
   contain
   > this:
   >
   >    HTTPAPI Ver 1.23 released 2008-04-24
   >
   >    OS/400 Ver V5R4M0
   >
   >
   >    New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819.
   >    ProtLoc=0
   >
   >    http_url_get(): entered
   >
   >    http_persist_open(): entered
   >
   >    http_long_ParseURL(): entered
   >
   >    DNS resolver retrans: 2
   >
   >    DNS resolver retry  : 2
   >
   >    DNS resolver options: x'00000136'
   >
   >    DNS default domain: APPN.SNA.IBM.COM
   >
   >    DNS server found: 123.45.6.7
   >
   >    DNS server found: 123.45.6.8
   >
   >    SetError() #7: Timeout occurred while trying to connect to
   server!
   >
   >
   >
   >    -       how can i solve this problem, anybody help me ?
   >
   >
   >      Many thanks in advanced.
   >
   >
   >
   >     ( Muito obrigado.)
   >
   >
   >
   >    Mário Rodrigues
   >    Analista/Programador
   >    Promosoft Financial
   >    [1]mario.rodrigues@xxxxxxxxxxxxx
   >    Tel.: (+351) 211 107 100 Fax: (+351) 211 107 103
   >    [2]www.promosoft.com
   >
   >
   _________________________________________________________________
   >
   >    Disclaimer/Implicações legais
   >    www.promosoft.com/disclaimer/e-mail
   >
   > References
   >
   >    1. mailto:mario.rodrigues@xxxxxxxxxxxxx
   >    2. http://www.promosoft.com/
   >
   >
   >
   >
   ----------------------------------------------------------------------
   --
   >
   >
   ----------------------------------------------------------------------
   -
   > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   ----------------------------------------------------------------------
   -
   ----------------------------------------------------------------------
   -
   This is the FTPAPI mailing list digest.  To unsubscribe, go to:
   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
-----------------------------------------------------------------------