ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Exposing AS/400 as a Web Service

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exposing AS/400 as a Web Service

    Hi All,

    Plese help me in knowing,

    How I can access legacy applications on AS/400 using webservice.

    If I say specifically;
    From front end application, I should recieve the request in XML form and our As400 program will process it and return the result in XML
    document form to front end.

    This should happen irrespective of any front end application

    So is there any
    1. Free tools
    2. Third Part tool
    3. Adapters
    or anything which could solve this



    Thanks and Regards
    Xcures

  • #2
    Re: Exposing AS/400 as a Web Service

    Hi here is an example based on powerEXT Core (Free Software)

    Code:
    /copy qsrc,pxapihdr General H-Spec's
    
    * powerEXT API Connectors
    /copy qsrc,pxapicgicn Basic HTTP connecter & Basic Services
    
    d s s 10i 0
    d dsp s 52a
    
    /free
    clearSrvPgm();
    
    // first receive the posted input
    s = getExtInputRaw();
    storeToStmf(s:'/receivedXML.txt':1208); // save input for demo
    
    
    // initialize the xmlReader
    xmlReaderInz(storeAddr(s):storeSizec(s));
    
    // read the XML
    dow xmlReader = 0;
      select;
        when xmlGetNode = 'driver' and xmlGetAttr = '';
          dsp = xmlGetData;
          dsply dsp;
      endsl;
    enddo;
    
    // send back a responce to the requester
    setContent('text/xml');
    xmlNode('result');
      xmlNode'driver':'':dsp;
    xmlEndNode();
    
    echoToClient();
    
    *inlr = *on;
    /end-free
    More information on http://powerext.com

    Comment


    • #3
      Re: Exposing AS/400 as a Web Service

      If you are wanting to expose a legacy RPG program (such as calling a program, passing it an order number, and it passes back some info like the date shipped ), then you can simply use the IWS. The IWS has a wizard that will create a webservice out of an RPG program. It will create a WSDL, and deploy the webservice to an application server. The IWS is free and comes automatically with the system.
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment


      • #4
        Re: Exposing AS/400 as a Web Service

        Hi!

        You can try to use gSOAP toolkit (See http://www.cs.fsu.edu/~engelen/soap.html) - it can generate code which works on IBM i. Of course, you will have some porting efforts. Agree with Michael - IWS is an option too.

        Comment


        • #5
          Re: Exposing AS/400 as a Web Service

          @Michael

          Today many only use SOAP (IWS) if they have to. REST is used for most webservices today and even the use of XML as format is declining while JSON is taking over. REST will also probably be depreciated in the coming years and will be taken over by websocket services (a new and upcoming W3C technology).

          Why is that?

          SOAP is a XML based fat protocol that takes up a lot of bytes and thereby bandwidth and it is not suited to communicate heavy traffic with many of the clients that uses webservices today such as browsers and APP?s. SOAP is designed for a single directional stateless environment and connections are based on ?one client at the time?. SOAP is a very formal protocol and will probably survive (like EDIFACT and X12) to accommodate exchange of complex business documents. It can also be validated against XSD schemas and Schematron but if that is done for each request it slows things down and makes it useless as a high performance webservice that expects total server turnaround processing time < 0.01 sec including socket I/O, XML reading of input, SQL processing and XML generating of the response.

          REST can be anything. Its format (XML, JSON or other) is bilateral agreed and can be very slim. REST is like SOAP designed for a single directional stateless environment and connections are based on ?one client at the time?. REST is like SOAP HTTP based and the HTTP protocol and headers are still in high performance environments a bottleneck.

          XHR (AJAX or products like HTTPAPI) are clients that uses SOAP or REST services and is designed to issue a request and get and answer and then disconnect (single directional PULL). In XHR (AJAX) today JSON is the preferred format since JSON can go directly into javascript objects without any conversion and thereby processing overhead.

          A typical XHR/REST/JSON based use you can see here where the REST service is called when you stop typing and return the search result of the typed input. (It could never be done so fast using SOAP):



          Websockets is the new W3C standard for bidirectional communication (PUSH/PULL). Unlike XHR and REST/SOAP websockets can be either single directional (stateless PULL) or bidirectional (statefull PUSH/PULL) so the server can PUSH data out to its connected clients in real time. Compared with the HTTP protocol it is much slimmer and one websocket server program can service thousands of clients in real time because it is a OO multithreaded program where each tread holds and services a client connection.

          A demo of websockets can be seen here:

          Another Milestone has been taken to introduce real-time technology to the web community. With the new jWebSocket Sencha Plug-in WebSockets are easily availab...


          Websockets is however only an emerging technology and not very well supported yet so HTTP/REST/XHR will continue to be used ?as first choice? for several years to come and many can?t imagine what kind of applications on IBM I would use bidirectional communications but let me remind those that read this that just a simple command such as SNDBRKMSG would require that the server is able to PUSH the message to the user and real time signaling to the user is not only limited to mail and stock quote applications that maybe today uses AJAX long poll.

          Now I?m not saying that one technology kill?s another overnight, WEB 1.0 didn?t disappear because WEB 2.0 emerged, but I see a clear trend and we have to embrace tomorrows technologies instead of continuously pushing and stretching yesterdays.

          Comment


          • #6
            Re: Exposing AS/400 as a Web Service

            Originally posted by Henrik Rutzou View Post
            @Michael

            Today many only use SOAP (IWS) if they have to.
            The OP mentioned having to send and receive in XML, so it appeared SOAP was a requirement. The IWS is still today the easiest and least expensive way to deploy legacy RPG applications and expose them as webservices. I received a new web service requirement this past week, from an outside entity, that requires SOAP. SOAP isnt going anywhere anytime soon.

            I do prefer JSON, because it is lighter weight, and because it is supported directly by javascript.

            I've been waiting for websockets for years. The issue with implementing websockets will be the same issue that Web 2.0 (and for that matter, any browser dependent new function) had, and that is that we have no control over browser versions in the public domain. It's easier to develop apps using new browser function enhancements for internal corporate use, because IT can mandate and upgrade all corporate user browsers to a level that supports the new function / feature. But we have no control over the public domain. And if we have to develop apps for the public domain, we have to deal with users on non-compliant browsers, sometimes for years. (Although if IE was simply abolished, this would solve a big chunk of the problem )

            If they ever get websockets fully implemented with all major browsers adopting them, and when we can get a majority of the public on those supported browser versions, then web sockets is going to be nice.
            Michael Catalani
            IS Director, eCommerce & Web Development
            Acceptance Insurance Corporation
            www.AcceptanceInsurance.com
            www.ProvatoSys.com

            Comment


            • #7
              Re: Exposing AS/400 as a Web Service

              If you're familliar with PCML, that is the correct way to go. Zendcore provides PHP script functions; all of which is supplied with the OS/400 at no additional charge. Let me know if you're interested.

              Comment


              • #8
                Re: Exposing AS/400 as a Web Service

                No need to use web services to call an RPG program. Zendcore has it's own web server that does all of the work. Using the PCML concept, it's very simple with PHP calling RPG programs & passing parameters both directions.

                Comment


                • #9
                  Re: Exposing AS/400 as a Web Service

                  We are currently using web services created by IWS which outputs XML. Is there anyway to "switch" this to use JSON in and out bound? Reason being, this XML is converted ultimately to JSON within our ExtJS application and we'd like to avoid the step.
                  Your friends list is empty!

                  Comment


                  • #10
                    Re: Exposing AS/400 as a Web Service

                    IWS on 7.1 TR 9 and 7.2 TR 1 has REST capabilities. It doesn't yet have JSON.

                    Comment

                    Working...
                    X