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

Re: WebService from AS400



   Hey Thomas,
   Thanks for the nice walk through.
   So, If I am following the path you laid out correctly, I need new
   machine to host this Tomcat server and the java webservice or exposed
   class(something i would be doing from the scratch)  which in fact
   consumes everything from the AS400 service program. Right?
   Thanks,
   Musthafa

   On Fri, Dec 25, 2009 at 6:10 AM, Thomas Raddatz
   <[1]thomas.raddatz@xxxxxxxxxxx> wrote:

     Musthafa,
     Here is how I provide web services:
     1. At first I write a RPG service program that implements the
     business logic of the web service. For
     me I call it the back end of the web service.
     2. Next I use SQL stored procedures to expose the procedures of the
     service program to the public.
     3. Now that I can access the procedures of my RPG service program
     with SQL it is easy to write a
     little Java class that can be deployed to Axis2 on a Tomcat server.
     Perhaps the following picture describes it better:
        Web Service Client
               |
               |  calls web service
               |
               *
        Java Class on Tomcat (3.)
               |
               |  does JDBC stored procedure call
               |
               *
        SQL stored procedure on AS/400 (2)
               |
               |  acts as a wrapper
               |
               *
        RPG service program
     Sample code:
     a) RPG service program procedure:
     ---------------------------------
      *
      *
     ===================================================================
     ==
      *  Retrieves basic system status information.
      *
     ===================================================================
     ==
      *  Parameters:
      *   i_reset          Reset status statistics.
      *                     *YES  Statistics will be reset to zero.
      *                     *NO   Statistics will not be reset to zero.
      *
      *  Returns:
      *   basicStatus      Result set with one row of type
     'basicStatus_t'.
      *
     ===================================================================
     ==
     P RetrieveSystemStatus_basic...
     P                 B                   export
     D RetrieveSystemStatus_basic...
     D                 PI
     D  i_reset                      10A   const  varying
      *
      *  Return value
     D basicStatus     DS                  likeds(basicStatus_t ) inz
     D                                     dim(1)
     D numRows         S             10I 0 inz(%elem(basicStatus))
      *
      *  Local fields
     D curTimestamp    S               Z   inz
     D ssts0100        DS                  likeds(ssts0100_t) inz
     D errCode         DS                  likeds(errCode_t ) inz
      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     - - - -
      /free
         if (i_reset <> '*YES' and i_reset <> '*NO');
            kill('Value of parameter ''i_reset'' is invalid: ' +
     i_reset);
         endif;
         QWCRSSTS(ssts0100: %size(ssts0100): 'SSTS0100': i_reset:
     errCode);
         curTimestamp = convertSysTimestampToRpg(ssts0100.curDateTime);
         basicStatus(1).systemName                    =
     ssts0100.systemName;
         basicStatus(1).currentTime                   = curTimestamp;
         basicStatus(1).usersCurrentlySignedOn        =
     ssts0100.usrSgndOn;
         basicStatus(1).batchJobsWaitingForMessages   =
     ssts0100.jobMsgWait;
         basicStatus(1).batchJobsRunning              = ssts0100.jobRun;
         basicStatus(1).batchJobsHeldWhileRunning     =
     ssts0100.jobHeldRun;
         basicStatus(1).batchJobsHeldOnJobQueue       =
     ssts0100.jobHeldOnJobQ;
         basicStatus(1).batchJobsOnAHeldJobQueue      =
     ssts0100.jobOnHeldJobQ;
         basicStatus(1).batchJobsOnUnassignedJobQueue =
     ssts0100.jobUnasndJobQ;
         EXEC SQL
          SET RESULT SETS FOR RETURN TO CALLER ARRAY :basicStatus
                                                 FOR :numRows      ROWS;
         return;
      /end-free
      *
     P RetrieveSystemStatus_basic...
     P                 E
      *
     b) SQL stored procedure:
     ------------------------
      *
      *   CREATE PROCEDURE jako2009.RetrieveSystemStatus_basic(
      *                                         IN  reset
     VARCHAR(10))
      *      EXTERNAL NAME
      *         'JAKO2009/RTVSYSSTS(RetrieveSystemStatus_basic)'
      *      LANGUAGE RPGLE
      *      PARAMETER STYLE GENERAL
      *      NOT DETERMINISTIC
      *      DYNAMIC RESULT SET 1
      *
     c) Java class:
     --------------
     public BasicStatusResponse retrieveBasicStatus(BasicStatusRequest
     request) {
        BasicStatusResponse response = new BasicStatusResponse();
         try {
            Connection cn = getConnection();
            CallableStatement stmt = cn.prepareCall("CALL
     jako2009.RetrieveSystemStatus_basic(?)");
            if (request.getReset().equals(Boolean.TRUE)) {
                stmt.setString(1, "*YES");
            } else {
                stmt.setString(1, "*NO");
            }
            stmt.execute();
            ResultSet rs = stmt.getResultSet();
            if (rs == null) {
               closeConnection(cn, stmt, rs);
               return response;
            }
            if (rs.next() == false) {
               closeConnection(cn, stmt, rs);
               return response;
            }
            response.setSystem(
                  rs.getString(BASIC_STATUS_SYSTEM_NAME));
            response.setCurrentTime(
                  rs.getTimestamp(BASIC_STATUS_CURRENT_TIME));
            response.setUsersCurrentlySignedOn(
                  rs.getInt(BASIC_STATUS_USERS_CURRENTLY_SIGNED_ON));
            response.setBatchJobsWaitingForMessages(

     rs.getInt(BASIC_STATUS_BATCH_JOBS_WAITING_FOR_MESSAGES));
            response.setBatchJobsRunning(
                  rs.getInt(BASIC_STATUS_BATCH_JOBS_RUNNING));
            response.setBatchJobsHeldWhileRunning(

     rs.getInt(BASIC_STATUS_BATCH_JOBS_HELD_WHILE_RUNNING));
            response.setBatchJobsHeldOnJobQueue(
                  rs.getInt(BASIC_STATUS_BATCH_JOBS_HELD_ON_JOB_QUEUE));
            response.setBatchJobsOnAHeldJobQueue(

     rs.getInt(BASIC_STATUS_BATCH_JOBS_ON_A_HELD_JOB_QUEUE));
            response.setBatchJobsOnUnassignedJobQueue(

     rs.getInt(BASIC_STATUS_BATCH_JOBS_ON_UNASSIGNED_JOB_QUEUE));
            closeConnection(cn, stmt, rs);
        } catch (ClassNotFoundException e) {
           throw new WebServiceException(e);
        } catch (SQLException e) {
           throw new WebServiceException(e);
        }
        return response;
     }
     This year I spoke about RPG and Web Services at the German Common
     conference. As part of the
     presentation I provided a little demonstration web service. It uses
     the QWCRSSTS API to retrieve
     system status information.
     Unfortunately the size of the complete project folder (containing
     Eclipse, Tomcat and the Eclipse
     workspace) is about 400MB. Currently I am trying to upload it to my
     Internet provider.
     However feel free to download the System i part and the pure
     Eclipse project folder from here:

     [2]http://www.tools400.de/Downloads/Samples/Common2009/Jako_2009_We
     b_Service_Project.zip

     [3]http://www.tools400.de/Downloads/Samples/Common2009/Jako_2009_Sy
     stem_i.zip
     Setting up a RPG web service is not as trivial as consuming a web
     service. You need RPG knowledge (of
     course) and you have to know a bit Java and Tomcat.
     If you can open your AS/400 to the public you may consider the new
     Web Service capabilities that were
     introduced with V6.1 and that are available for V5R4 by PTF. Here
     is an article about it that Scott
     published back in 2008:

     [4]http://systeminetwork.com/article/ibms-integrated-web-services
     Regards,
     Thomas
     Mohamed Musthafa Safarulla schrieb:

   >    I need to serve, I already consume using HTTPAPI. Probably this
   is not
   >    the right place to ask.
   >    Thanks,
   >    Musthafa
   >
   >    On Thu, Dec 24, 2009 at 7:57 AM, Nicolas Machado (Metodo S.A.)

   >    <[1][5]nicolas.machado@xxxxxxxxxxxxx> wrote:
   >
   >        mushtafa, you need to serve or consume a web service ?
   >        if the second one is your need, httpapi is the answer.
   >        Best Regards
   >        2009/12/23 Mohamed Musthafa Safarulla

     >        <[1][2][6]mohamedmusthafa.safarulla@xxxxxxxxx>

   >
   >          I know lot of you guys are far advanced and using AS400 as
   a
   >    some
   >          machine about to be kicked out. For me it has been the the
   bread
   >        and
   >          butter for a good 4 years now. But seeming now i can see
   this is
   >        not
   >          the plat for i can hang on to for a long time as people are
   so
   >        hush
   >          hush about new technologies.
   >          I was provided with an as400 application, client access. I
   >    picked
   >        up
   >          the source code well, understood the business well, but
   never
   >        felt
   >          myself moving far ahead with technologies. When i see
   people are
   >        doing
   >          great things with Java, PHP & what not with AS400. They are
   >    using
   >          WebSphere developement server to create webservices, create
   >        program
   >          sources with good GUI.
   >          I was always in a bubble and when i looked at the system
   >        installed
   >          softwares latest Java is there and we had the CDs of
   WebSphere
   >          developement center etc. I never hooked up with it, I
   realized
   >        all
   >          these very lately and i know there are so many out there
   like me
   >        would
   >          like to hear on my concerns.
   >          Please guide and en-light me/us
   >          Thanks,
   >          Musthafa
   >
   >
   >
   -------------------------------------------------------------------
   >          ----
   >          This is the FTPAPI mailing list.  To unsubscribe, please go
   to:

     >
     [2][3][7]http://www.scottklement.com/mailman/listinfo/ftpapi
     >
     >
     -------------------------------------------------------------------
     >          ----
     >        --
     >        _______________
     >        .:Nicolás Machado
     >      References
     >        1. mailto:[4][8]mohamedmusthafa.safarulla@xxxxxxxxx
     >        2.
     [5][9]http://www.scottklement.com/mailman/listinfo/ftpapi

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

     >      [6][10]http://www.scottklement.com/mailman/listinfo/ftpapi
     >
     -------------------------------------------------------------------
     >      ----
     >
     >    --
     >    Thanks,
     >    Musthafa
     >
     > References
     >
     >    1. mailto:[11]nicolas.machado@xxxxxxxxxxxxx

   >    2. mailto:[12]mohamedmusthafa.safarulla@xxxxxxxxx

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

   >    4. mailto:[14]mohamedmusthafa.safarulla@xxxxxxxxx

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

   >    6. [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 is the FTPAPI mailing list.  To unsubscribe, please go to:
   [18]http://www.scottklement.com/mailman/listinfo/ftpapi
   ----------------------------------------------------------------------
   -

   --
   Thanks,
   Musthafa

References

   1. mailto:thomas.raddatz@xxxxxxxxxxx
   2. http://www.tools400.de/Downloads/Samples/Common2009/Jako_2009_Web_Service_Project.zip
   3. http://www.tools400.de/Downloads/Samples/Common2009/Jako_2009_System_i.zip
   4. http://systeminetwork.com/article/ibms-integrated-web-services
   5. mailto:nicolas.machado@xxxxxxxxxxxxx
   6. mailto:mohamedmusthafa.safarulla@xxxxxxxxx
   7. http://www.scottklement.com/mailman/listinfo/ftpapi
   8. mailto:mohamedmusthafa.safarulla@xxxxxxxxx
   9. http://www.scottklement.com/mailman/listinfo/ftpapi
  10. http://www.scottklement.com/mailman/listinfo/ftpapi
  11. mailto:nicolas.machado@xxxxxxxxxxxxx
  12. mailto:mohamedmusthafa.safarulla@xxxxxxxxx
  13. http://www.scottklement.com/mailman/listinfo/ftpapi
  14. mailto:mohamedmusthafa.safarulla@xxxxxxxxx
  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.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------