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

RE: Iseries calling web service in JSON format



   I'm very sorry if I have offended Scott, danish humor can be
   very sarcastic and provocative.
   I build my products on the shoulders of experts such as Scott,
   Mel and a "John Doe Danish Batch Programmer" who primearly uses
   their time on the lower level techniques of what is possible on
   an iSeries Server.
   Without people from Rochester, that provides i5/os, and the above
   mentioned guys, my products would have been impossible to make.
   But their expertise dosn't automatically make them experts in any
   question on how to do programs in an efficient manner ...
   BUT, never critise others unless you have another solution ... and
   here it is - ILOB for HTTPAPI:
   *=====================================================================
   * powerEXT HTTPAPI Sample program
   *=====================================================================
   /copy qsrc,pxapihdr      General H-Spec's

   * powerEXT API Connectors
   /copy qsrc,pxapicgicn      Basic HTTP connecter & Basic Services
   /copy qrpglesrc,httpapi_h  Scott Klement's HTTPAPI
   // Clear The Service Program and Responce Object
   clrSrvPgm();
   setContent('*none');
   // Generate Structured (*on) or Compressed Code (*off)
   setGlobalTab(*on);
   setGlobalNL(*on);
   // Create your JSON Object with Node Support
   jsonNode('*object');
     jsonNode('*object':'metaData');
       jsonNode('*string':'totalProperty':'totalRows');
       jsonNode('*string':'root':'rows');
       jsonNode('*string':'id':'RRN');
       jsonNode('*array':'fields');
         jsonNode('*object');
           jsonNode('*string':'name':'RRN');
         jsonEndNode();
         jsonNode('*object');
           jsonNode('*string':'name':'WAWUSR');
         jsonEndNode();
         jsonNode('*object');
           jsonNode('*string':'name':'WAWUNA');
         jsonEndNode();
         jsonNode('*object');
           jsonNode('*string':'name':'WARCUD');
           jsonNode('*string':'type':'float');
         jsonEndNode();
       jsonEndNode();
     jsonEndNode();
     jsonNode('*number':'totalRows':%char(sqlCount));
     jsonNode('*array':'rows');
   // do some loop to create JSON Rows
       jsonNode('*object');
         jsonNode('*number':'RRN':%char(RRN));

         jsonNode('*string':'WAWUSR':WAWUSR);
         jsonNode('*string':'WAWUNA':WAWUNA);
         jsonNode('*number':'WARCUD':%trim(%editc(WARCUD:'P')));
       jsonEndNode();

   // end loop

   // End the JSON Object
     jsonEndNode();
   jsonEndNode();
   // Send the file to a Client with CGIDEV2
   echoToClient();
   // Or Store the file in IFS
   echoToStmf('/myfile.json':1208);
   // Or send the file to a Server with HTTPAPI by
   // Retrieving the Responce Object Buffer Pointer and Size
   myPointer = bufAddr();
   mySize = bufSize();
   http_url_post ....
   // Here is a XML example:
   echo('<?xml version="1.0"?>');
    xmlNode('AccessRequest':'xml:lang="en-US"');
      xmlMode('AccessLicenseNumber':'':'UPS_LICENSE');

      xmlNode('UserId':'':UPS_USERID);
      xmlNode('Password':'':UPS_PASSWD);        ´

    xmlEndNode();
   echo('<?xml version="1.0"?>');
    xmlNode('TrackRequest':'xml:lang="en-US"');
      xmlNode('Request');
        xmlNode('TransactionReference');
          xmlNode('CustomerContext':'':'HTTPAPI EXAMPLE16');

          xmlNode('XpciVersion':'':'1.0001');
        xmlEndNode();
        xmlNode('RequestAction':'':'Track');
        xmlNode('RequestOption':'':'activity');
      xmlEndNode();
      xmlNode('TrackingNumber':'':TrackingNo);
    xmlEndNode();
   - you don't have to write tag names twice
   - you don't have to worry about ending tags
   - you don't have to worry about special char encoding
   - you write less
   - you can output the file into IFS for test
   - you can structure you code for readability
   - you can compress your code for production and speed
   - you can use the same technique in CGIDEV2, HTTPAPI and FTPAPI
     or anywhere else
   - you can use the same methods for HTML, XML and JSON
   - you have no JSON comma hell
   - you don't have to use templates
   - you can have service programs that also writes to the buffer
   - you are not restricted to 32767 bytes

   Richard Wilson <Richard.Wilson@xxxxxxxxxxxxxxx>
   Sent by: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

   12-10-2009 10:47

                             Please respond to
        HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

                                                                       To

   HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>

                                                                       cc

                                                                  Subject

   RE: Iseries calling web service in JSON format

   Oh!
   I read it and thought Henrik was using irony and sarcasm (?) - well,
   something like that, to take a poke at the original questioner..
   ..   And I really fail to see why Scott would even have the faintest
   of inclination to feel bad about not having implemented some new gee
   gaw into the product.  Isn't the normal run of things that someone who
   needs an 'extra'  works on it, implements it, and shares at around for
   everyone else to help improve the product.
   My vote is for Scott to feel good about all the stuff this code does,
   and get a warm feeling from all the thanks from all the people round
   the planet who appreciate his pioneering and continued support..
   But that's just me..
   Richard
   >
   > Michael Ryan wrote:
   > >    I think Henrik is volunteering to implement the CGIDEV2
   memorymodel
   > >    for ILOB (wtf) that is. Plans include unit testing, regression
   > >    testing, and packaging. On his own time.
   > >    Scott...you're the uber programmer...thanks for writing the
   code you
   > >    write.
   >
   > Hear, hear!
   >
   > And Henrik, one other thing while you're at it: make it run as far
   back
   > as V4R4, and compilable using V4R2 tools.
   >
   This document may contain confidential information intended for the
   addressee only. Any views or opinions presented do not necessarily
   represent those of Newcastle Building Society/Newcastle Financial
   Services Limited/NBS Mortgage Advisor Limited/Newcastle Mortgage
   Services Limited, hereinafter referred to as NBS group.
   If you are not the intended recipient, any disclosure, copying, or
   reliance upon this E-mail is prohibited. If you have received this
   document in error, please notify the sender so that NBS group may
   arrange for its proper delivery. All e-mails are scanned for viruses
   and other unacceptable content, which may result in non-delivery of a
   small proportion of e-mails. Anyone sending urgent/important e-mails
   should therefore confirm delivery.
   NBS group does not enter into contracts by means of Internet or e-mail
   and staff are not authorised to enter into contracts in this way.
   NBS introduces to Newcastle Financial Services Limited (NFSL).  NFSL
   is an appointed representative of Openwork Limited, which is
   authorised and regulated by the FSA. Newcastle Building Society is
   authorised and regulated by the Financial Services Authority
   (www.fsa.gov.uk/register/) and is entered in the Financial Services
   Authority Register under Registration No. 156058.
   Web site: www.newcastle.co.uk
   ----------------------------------------------------------------------
   -
   This is the FTPAPI mailing list.  To unsubscribe, please 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
-----------------------------------------------------------------------