IBM's Integrated Web Services

Article ID: 56787

Did you know that, as of a recent PTF level on V5R4 (or later), i5/OS comes with a built-in web services server? This tool is specifically designed to let you easily export your RPG or Cobol routines as web services. This new support does require that Java be installed on your machine, but it doesn't require WebSphere Application Server (WAS). The services are made available through the Apache HTTP server.

And it costs you nothing. It's built in to i5/OS!

IBM has set up a web page that explains what software you need installed, which PTF levels you have to have, and so on, in order to use this new support. IBM also provides a great step-by-step tutorial with screen shots explaining how to create your first web service.

To learn more, check out IBM's "Integrated Web Services for i" website:
ibm.com/systems/i/software/iws

  • To see the system requirements, click the Support tab.
  • To see the tutorial, click the Getting Started tab, and then click Learn Web services server.

So far, I haven't tried using this tool for any production software, but I did set up a quick proof-of-concept program. I decided to write a simple RPG program that looks up the description of a particular item number. Here's the RPG code:

     FITMMAST   IF   E           K DISK    USROPN

     D TESTWS          PR                  ExtPgm('TESTWS')
     D   peItem                       5p 0 const
     D   peMsg                       80a
     D TESTWS          PI
     D   peItem                       5p 0 const
     D   peMsg                       80a
      /free
            *inlr = *on;

            open ITMMAST;

            chain peItem ITMMAST;
            if not %found;
               peMsg = 'Item ' + %editc(peItem:'X') + ' not found';
            else;
               peMsg = imDesc;
            endif;

            close *all;
            return;
      /end-free

As you can see, the program accepts parameters for the item number and description. This program can just as easily be called from another program. It could pass the item number and a variable for the description, and my RPG code would look up the item in the item master (ITMMAST) file and return the description.

I compiled this program with the following command:

   CRTBNDRPG PGM(TESTWS) +
             PGMINFO(*PCML) + 
             INFOSTMF('/home/klemscot/testws.pcml')

This command compiles my program, of course, but it also generates a Program Call Markup Language (PCML) document -- an XML document that describes my program's parameter list. The Web Services wizard uses that PCML document to determine how to call my program and how to generate the Web Services Description Language (WSDL) for it.

Now that I've created my program, I create a web service for it by going to the Integrated Web Services for i website and following the instructions in the Getting Started tutorial. After that's done, presto! I have a web service that returns my item description.

Okay, this is HTTP, so can the service be called through a Reverse Proxy, or does my i need to be visible to the internet?
One thing that caught me out was that if you are on V5R4 and you enter the PGMINFO keyword in the headers specifications in SEU it will show this as an error; it does not recognize the keyword. If you just ignore this error and save the source it will compile fine.
You should have the PTF Alex mentioned as part of loading the necessary group PTFs on V5R4 to get the Web Services Wizard function. While SEU or WDSC will not recognize the keyword, you can still save and compile. Stocking the PCML in the progam or module allows the Create a Web service wizard to access it directly. While the function was available on V5R4 starting with level 11 of the HTTP group PTF, I suggest you make sure to be at the latest level of both the HTTP (13) and Java groups. Also, if you have special characters in your parameter names, (ex.: @Parm1), wait until PTF SI31751 is available.
Another option to store a PCML document within a *PGM or *MODULE is to include this statement on RPG code:
H PGMINFO(*PCML:*MODULE)    
PTF 5722WDS SI27061 are required.

ProVIP Sponsors

ProVIP Sponsors