Many of you have seen one of the IBM Watson ads on TV and in print and been impressed by the powerful capabilities that IBM Watson is offering. If you’re a RPG developer then you’ve likely wished you could leverage one or more of the IBM Watson services from within a RPG program.

We have good news for you.

RPG-XML Suite takes your wish and makes it a reality. RPG-XML Suite even makes the process easy along the way! Using a minimal amount of RPG code, RPG-XML Suite allows your RPG projects to participate in the growing ecosystem of IBM Watson. (As well as a growing number of cloud based web services from other companies.)

In this post, I’m going to detail just how simple it is to use IBM Watson’s Document Conversion API to convert a PDF document into a HTML document. Should you decide to follow along by implementing this code yourself, you’ll need a Bluemix account — Bluemix is IBM’s cloud platform for services, infrastructure and more. You will need to have RPG-XML Suite installed as well, so if you’re not already a RPG-XML Suite customer, you can download our 30 day free trial from the form at the bottom of this page.

Signup for a free Bluemix account here: https://console.bluemix.net/registration/

Once you’re logged into an active Bluemix account, you can create your Document Conversion service by selecting Watson from the catalog of available services, and then further select the Document Conversion service. After your service is created, you can retrieve the credentials needed to access it:

With the service credentials in-hand, we’re ready to step thru the RPG-XML Suite code for calling the service. To make use of this code, you’ll need a current version of the RPG-XML Suite software, preferably version 3.3x or higher. If you’re not a current RPG-XML Suite customer, but would like to try out the code from this post, you can download at the bottom of this page.

Developing the RPG-XML Suite code was accomplished by closely examining the outstanding documentation and demos at mybluemix.net:

https://document-conversion-demo.mybluemix.net/

The basic steps to be performed by the RPG-XML Suite code are as follows:

  • Construct the required content disposition boundaries and within them the configuration data specified by the IBM Watson API reference.
  • Convert the assembled content to ASCII.
  • Retrieve the binary (ASCII) contents of the PDF to be transmitted for conversion and append it to the content already assembled.
  • Transmit the content (without conversion since it is already in ASCII) to IBM Watson while specifying the credentials needed to authenticate to the IBM Watson service.
  • Process the returned HTML content as your project dictates!

As part of the step to transmit the data to IBM Watson, you can also generate a log file for the actual transmission to IBM Watson, which can be very helpful in troubleshooting any errors that cause the transmission to fail. The log contains the full formatted request data that was transmitted, as well as the complete response sent back by IBM Watson. So if you have any problems implementing the code, be sure to specify a log file and refer to it when troubleshooting.

Below is an example PDF that was transmitted by the RPG-XML Suite code, and next to it is the returned response:

 

 

Just scroll to the bottom of the page for the actual RPG-XML Suite code used to achieve this result. Note that the Document conversion API supports other conversions besides PDF to HTML, so check the documentation if you are interested in converting other types of documents.

Let us know what you think of IBM Watson services in the comments section below!

Do you have a specific project that might be a good fit for IBM Watson, but you’re unsure how to tackle it in your RPG environment? We are here to help you create a solution for your business need. In many cases, we can even assist with a free proof of concept that will quickly demonstrate the power and flexibility RPG-XML Suite can bring to your organization.

Contact us if you have specific questions about RPG-XML Suite – we are always available to help!

If you would like to play around within RPG-XML Suite on your own time, just head to the bottom of this page to download a free 30 day trial. 

 

Download a 30-day trial of RPG-XML Suite and get started today!

  • This field is for validation purposes and should be left unchanged.

Get Social

Share to your favorite social platform