The IBM i OS Contains Everything Needed to Create Web Services
Leveraging Web services for your IBM i applications allows you to continue to use your applications of today while also enabling you to repurpose key components in other applications or as the conduit between your UI and your back-end data and key business logic.
Web services can be a key component to a modernization project on IBM i. A “service” is a callable interface/method/routine that executes some business logic. It can be complex or very simple. What makes this different is this that it’s callable from the Web, providing a highly reusable interface that can be called from anywhere.
On IBM i, using Web services has never been easier. The OS includes an integrated Web services (IWS) runtime environment. The IWS is utilized today by thousands of IBM i users for a wide array of production services. In June 2014 IBM shipped the new Liberty and JAX-WS based runtime environment. This new technology base is built on the latest industry technologies to ensure a solid base for the future. The IWS server has been built and designed with the RPG or COLBOL developer as its primary user. The IWS support not only contains the necessary runtime environment for running Web services in an enterprise production environment, it also has wizards to help RPG and COBOL developers quickly and easily create and host Web services over back-end ILE programs with virtually no knowledge of the Web side of things. The best part about this support? Because it is part of the IBM i OS, you don’t need to purchase or install anything.
Getting Started
To get started with the IWS support, it’s recommended that you have the latest HTTP PTF and Java* PTF group levels installed. This will ensure you have access to the new Liberty-based IWS engine as well as any other goodies. This support applies to all currently supported releases of IBM i. Once your PTF group levels are set, (again this is not necessary unless you want to leverage the new Liberty-based server, which I highly recommend) you can create your Web services runtime hosting environment easily by walking through the create wizard found in the left navigation pane of the Web Administration GUI (open a browser, enter http://hostname:2001/HTTPAdmin) as shown in Figure 1 (right). Once your server is created and running, which should only take a couple of minutes, you are ready to deploy your first Web service.
When it comes to creating a Web service over your RPG or COBOL programs, the hard part lies on the ILE side, where the real work needs to happen. Because you are creating a service callable from anywhere, the RPG or COBOL program needs to conform to three rules:
You have to be using an ILE version of RPG or COBOL. The older versions are just not supported with the IWS-based support.
Your function that you are creating as a service must be a stateless callable program or service program. It can’t be dependent on an input or other things.
When you compile your code, you must specify the Program Call Markup Language (PCML) option as either a program header option or on the create program command. The PCML is a special object that’s embedded with your compiled program and tells the IWS support what the input and output parameters are for you program.
Once your ILE code is set, the fun part can begin. Creating your Web services is easy. From the Web admin GUI, click on the Manage Deployed Services link. Within this interface, click the Deploy button to start the Deploy a service wizard. This wizard consists of several steps; most are for more advanced features. You really only need to care about a few:
Specify the ILE program or service program object that contains your back-end function.
Define a name for your service. The wizard provides a default value based on the name of the program you specified, but I would recommend specifying a meaningful value, as it will be beneficial later when you are trying to remember what you just did.
Specify what functions you want to expose within this Web service. You can do this in several ways: one large Web service with many functions exposed or an individual Web service for each function you want to expose. I personally am a big fan of simplicity, and would create a simple Web service for each function.
R Update the input and output fields. You will notice the fields are already defined, but likely they aren’t completely accurate. If you’re returning an output structure, for example, it will likely be marked “input/output.” It’s best if you can change that to output and then be sure to designate the correct structure return size. This ensures that the IWS wrapper code handling the call back and forth between the world of the Web and the ILE program can process that data efficiently.
Specify the user ID that this ILE program will run against.
Specify the library list that will be used. The library list can easily be updated at a later time, so here you could specify test data library to get started and then update with the production library later.
R Click on “Next” on any additional screens and hit “Finish.” Within a few seconds the wizard will create the Web services wrapper and deploy it into your Web services runtime environment.
At this point you are set and ready to go! Within the deployed service interface, is a link to the Web Services Descriptive Language. That is the object you will need to send to the caller of your Web service. Try it out for yourself; click on the Test button to launch the IWS testing interface, specify your input values and verify your Web service is working as expected.
Helpful Wizards
Getting starting creating and hosting Web services for the IBM i has never been easier. A complete set of wizards help guide you along the path. For those that are wondering, the IWS support also has a complete set of callable scripts and interfaces to give you the ability to automate or easily move these services from one system to another.