Open Source on IBM i

BlueDroplet - Next Steps

For those of you who don't know yet: BlueDroplet is a native REST framework for all ILE languages on IBM i. BlueDroplet consists of multiple ILE modules which are bound to an ILE program. Here is an overview of the structure of such a program.

BlueDroplet is a work-in-progress. Some rudimentary things already work but other required things for a "complete" REST microservice still doesn't work, f. e. PUT and POST requests.

Though if the service is only about providing data and not taking data as input you are ready to go with BlueDroplet.

Is BlueDroplet production-ready? No. But it is an already useful framework none-the-less. You can take it to get your feet wet and your hands dirty with developing your first REST microservice on IBM i without spending a dime. You also don't have to get some trial license and don't have to get and install a licensed program. Just download the source and compile it.

With BlueDroplet you can learn what it takes to build such a service. And what is most important is to realize what works for you and your environment and what doesn't. F. e. how "big" should a model be? Or do you need more specific/smaller data models which may provide you with more flexibility. If the model is too small the client may need to make many requests to the server before having anything useful to display to the user.

Smaller models may also mean more microservices. This requires more attention in the administration.

You also learn how to organize your code so that you can use it for the REST service and also use it for your 5250 programs. Same code base. Just wrap it up in service programs.

There are many articles and blogs about REST services. Take a broader view and explore the internet for information about REST. A good source of information for me has been DZone.

And why now such an article about BlueDropet? Yes, for some time now the framework was able to successfully process GET requests. But now it also supports processing the URL path and query parameters. This is essential in communicating with modern web frameworks because many use JSONP. To provide the data as JSONP the REST service needs to inspect the query parameters and use the callback parameter in the request response.

F. e. the URL of a HTTP request with such a callback parameter may look like this:


You can get the callback query parameter value with this code:

callbackId = droplet_http_getQueryValue(httpMessage : 'callback');

The REST service now builds the return data and wraps the callback parameter value around it like this:

angular.callbacks._0({'id':123, 'name':'Michael Meier'})

You can also query the path elements like this:

customerId = %int(droplet_http_getPathElement(httpMessage : 1));

So what are the next steps?

As we have now support for getting the path elements and query parameter values I can pick up development of the show case for BlueDroplet again, see project Store Management.

So get your hands dirty and take some REST. ;-)


Tags : bluedroplet