Calling Out to Public Web Services Right from RPG Applications

Call web services like Google geolocation, the weather service, Amazon services, Shopify and Logistics with just a few lines of code.

Video Transcript

Welcome to this Eradani video on calling out to public web services right from your RPG applications. Many IBM i users have approached us lately looking for help in integrating public web service data into their IBM i applications. We’ve had requests for integrations like Google Maps, weather, and logistics information. In this three-minute video, we’ll look at how easy it is to access these services right from RPG using Eradani Connect.

And I’m going to start right from the green screen, and we’re going to run a command display weather forecast. This is a command we’ve written that will go out and call out to the weather service and get the weather forecast. So notice I can put in the latitude and longitude for where I want the weather forecast, or I can actually just key in an address, and we’ll go ahead and do that, and we’ll see how the weather is today at the White House, and send that in. And so now we’ve run that web service call, and let’s go ahead and look at our results. And here I can see I’ve gotten the forecast information back. So right from our RPG code, we called out to a weather service API, we got the weather forecast, and now we have that data available to us to use in our RPG program. So we can put it in the database, we can add it to our business process, we can do whatever we want with that data. And let’s take a look at the code that was required in order to do that. So all I needed to do was describe the data. So I identify the fields. So I’ve got the latitude, longitude, the address, and then a field for the data coming back. And then I call this Eradani Connect procedure, Eradani Connect send request, which sends the data out to the web service. And then I simply do this call out to another Eradani Connect procedure, Eradani Connect receive result, which brings the result back to my RPG program. So that’s basically all I have to do in the RPG. Describe the data, do the call out to Eradani Connect to do the send, do the call out to Eradani Connect to get the data back. Now under the covers, Eradani Connect is actually going to run the web service with some JavaScript code. And here’s what that JavaScript looks like. Now we actually provide this JavaScript code in template programs that you can just cut and paste.

But I’ll explain what we’re actually doing here. So here, first, we have in the JavaScript the actual description of the API. So we have the URL where to get to it and our API key. And then down next, we have the actual call to the Weather Service API. And then we have the function that returns the data back to the RPG program. So basically, this is all the JavaScript you need in order to run this process. So we have a few lines of RPG code, a few lines of JavaScript. And that’s all we need to do in order to run the web service call. Now under the covers, Eradani Connect is actually doing all of the work like handling the authentication for you. So it’s ensuring that you’re authenticated to the web service. It’s including the code from the web service provider, their SDK, that helps you call that API appropriately. It does all the translation between JSON and IBM i native. It provides the latest cipher suites to ensure that your requests won’t get rejected. It manages the IBM i connections, and it supports the asynchronous nature so that when you send out a request, if the web service isn’t available, it will queue up those requests and run them later, and it’s extremely fast.

And that’s basically all you need to do in order to run your web service right from your RPG application. If you need more information, you can reach us at or through our email at or check out our other videos.