Skip to main content

Leveraging IBM i and RPG for Web Servicing

Another day in the life of a developer as another web service takes to production. Not an extraordinary task but this time the process was smooth sailing. What made it so painless?  What led to the decisions of using certain programs over others? In this article I will explain why I chose IBM i as the platform, RPG as the programming language and ILEastic as the web service framework of choice. I will cover the requirements, the pros and cons, and take a quick look at other programming languages and frameworks.

The web service in question is about providing the shipping addresses of customers, nothing special. The data is stored in a table on the IBM i server.

Some of the technical requirements were:

  • Hosted on-site (as it is only locally used)
  • Support access Db2 on IBM i
  • JWT support
  • Produce JSON
  • Support OPTIONS HTTP requests
  • REST like request path
  • OpenAPI compatible web service

Choosing RPG and IBM i

The requirements didn't specify a programming language or a platform where the service needs to run. The programming languages I could choose from included Java, TypeScript and RPG.

I decided that out of all of the options listed above, RPG was the perfect fit for this web service.
Some of the benefits of RPG included:

  • Always available database connection, with no hassle in database connection pools or configurations
  • Native battle tested HTTP server framework: ILEastic
  • Fast and feature-rich JSON library: noxDB
  • A very small number of dependencies (four other software libraries)
  • No extra tooling necessary
  • Good response times (< 20ms for this particular web service)
  • Extremely small memory footprint (< 10 MB)
  • No extra training or tooling for deployment and maintenance

Regarding the platform choice: the acceptable programming languages are all available on IBM i. Knowing that IBM i is one of the safest and most stable platforms the choice to use it to run the web service made the choice a no brainer. IBM i has also a track record of being backward compatible, meaning your investment in your new web service remains even in five or 10 years (and probably even further).

As most applications are backed by a database, the integrated Db2 on IBM i is a perfect match for our web service. Coupled with the native programming language RPG, it gives you a super fast database access as database functions are first-class citizens in RPG.

RPG: A Minimal Number of Dependencies

One thing I like most about RPG is that you have a very small and manageable amount of dependencies with no extra tooling needed. Let’s take a look at the numbers:

RPG: Four dependencies
Java: > 40 dependencies (Helidon, Quarkus)
TypeScript: > 400 dependencies (Express)

Note: These numbers reflect my typical setup for a web service with database access.

You might be saying, “I can get away with fewer dependencies with a different framework!” Yes, perhaps you can. However, those numbers are from projects which use the basic features of those frameworks, reflecting my typical setup for a web service project with database access. The aim was simplicity. With less features and much more effort you probably can get those dependencies down. But simplicity results in less development time and will save you a lot of stress.

In my opinion RPG wins this, hands down!

No Extra Training or Tooling in RPG

Another big advantage in using RPG with ILEastic for web services is that it blends seamlessly into existing infrastructure and tooling.

The web service program written in RPG is another ILE program. There’s nothing special about it, no magic or special treatment needed. Simply start it like any other normal ILE program and include it into your workload on the IBM i server as you normally would with programs. You can manage and monitor it as any other program on the IBM i server—making it so much easier to hand it over from development to DevOps.

From Dev to DevOps

A smooth transition to the DevOps and the communication with the web service are equally important.
ILEastic supports everything we need to create a pretty web API. It is easy to create an OpenAPI document which matches the web service. There are several free and available tools out there for designing such documents. Some of them include:

This OpenAPI document coupled with the Swagger UI project can easily be hosted on the IBM i server with the Apache HTTP server. You just need to point your fellow front-end developer to the Swagger UI URL and they will be very happy.

Providing an OpenAPI document made the job for the consumer much easier, it shows that your web service is very likely compatible with the rest of the world.

There is nothing distinct about a web service written in RPG with ILEastic, and that’s a good thing. It has a similar feel to other web services. The consumer doesn't have to learn anything new in order to use this web service as it is cohesive with the rest of the applications and web services.

ILEastic and noxDB Development

"Nothing special" also applies to the development with ILEastic, in the best possible way. ILEastic is provided as a service program and a copybook. Simply include the copybook into your source and bind your program object to the service program. You can build your web service program object with every tool out there. It integrates perfectly into any existing environment (i.e., Change Management Systems), but it also works well with tools like Make or Bob.
ILEastic's API is well-written, feature-rich and fully documented. It also supports HTTP methods which are not commonly used (depending on how deep you are into this topic) such as HEAD, OPTIONS or PATCH. The plugin system allows you to handle generic tasks like authentication or CORS at a single point and plug it into your setup.

Another positive about using ILEastic is that it lets you use whatever you want for content creation. This is where noxDB comes into play, an ILE service program that lets you parse and generate JSON and XML. It also has an SQL interface so you can directly generate JSON from SQL. With noxDB you have full control over your JSON output. You can start your development with designing your web API with your favorite OpenAPI editor and then implement it with ILEastic and noxDB. The combination of ILEastic and noxDB is like peanut butter and jelly. There is nothing better!

Congruent Concepts

What is even better is that you don't need to learn anything conceptually new when you are coming from the Java or Node.js world. It works the same: configure the embedded server, write the end point functions, configure the routes to your functions and, last but not least, start the server. With the exception of all the advantages you get with the ILE environment and having Db2 on IBM i, you will already know what to expect.

Web Services and More on ILEastic

I hope this article answered all your questions. Grab your peanut butter and jelly and start cooking some great web services on IBM i. Enjoy!

If you’re looking for more technical details about ILEastic you can find a tutorial here.

Both projects—ILEastic and noxDB—are open source and come with several examples which you can find in their code repositories.

Happy web servicing!