Midrange News for the IBM i Community


Posted by: TFisher
Web Services on the iSeries using RPG
has no ratings.
Published: 01 Nov 2012
Revised: 23 Jan 2013 - 4111 days ago
Last viewed on: 26 Apr 2024 (13242 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Web Services on the iSeries using RPG Published by: TFisher on 01 Nov 2012 view comments(10)

I am curious if anyone on this forum has developed any web services for the iSeries and using RPG?

 

I am curious as to whether web services would be sucessful using RPG and how easy it would be to implement authentication in services that request security.

 

I am thinking the iSeries and RPG would be a good fit for many types of web services and I am wanting to pursue learning how to build such a process. 

 

Any feedback and any tips would be appreciated. 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: clbirk
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 24 days 9 hours 15 minutes ago

basically what you are after is something opposite of call a web service, but to be the server of such.

At common, I attended a class that scott klement put on about how to set up rpg programs to listen on a port and that is what you are talking about doing, you can see the presentation slides here:  http://www.scottklement.com/presentations/

 

Of course in a sense of speaking if php through the xmltool kit or the easycom calls an rpg program that is like a webservice or could be.

 

I mean you could have php running on your box, and for example, say you needed to know the balance of an account.  You MIGHT go and do something like:

 

www.mydomain.com/getbalance.php?account=12345  and this program then would call an rpg program that would service it and then the php would return. This would be the i doing a web service

 

Of course with cgidev, you could do it directly with rpg and not have the php in such.

You get into whether you are going to do REST or SOAP and if they are going to POST or GET.  REST is by far simplier in my opinion.

 

Just remember if you do a GET or POST of query string variables, you need to scrub trim them to avoid things like sql injection and cross !--script--ing, etc.

A bad practice (in pseudo code would be)

 

IF $_GET['account'] blah blah blah

 

far better to transfer all query string variables into a "field" so if you need to run a function on them, you can, that is.

$account =$_GET['account']

if $account blah blah blah

 

so that you really can say:  $account = htmlscrubtrim($_GET['account'])  where htmlscrubtrim takes care of injection etc. issues.

 

 

 

 

 

 

 

 

Posted by: Ringer
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 23 days 18 hours 36 minutes ago

http://your400:2001/HTTPAdmin lets you turn lets you turn any callable (non-5250) RPGLE program into a SOAP XML (WSDL) web service. It creates java wrappers that call the RPG (*PGM or *SRVPGM) on the backend.

The disadvantage (might not exist these days) is that the RPGLE needs fixed length parms. The web likes to pass in any length parms. Think of the web passing in a big XML string for sales order lines. With RPG, you need a fixed length array and the web needs to pad out the unused elements. And the RPGLE needs to be compiled with the PCML option. Some parm types do not map to PCML.

Again, my research is a few years old, that limitation might not exist anymore.

http://systeminetwork.com/article/ibms-integrated-web-services
http://ibm.com/systems/i/software/iws

Chris Ringer

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 23 days 18 hours 15 minutes ago

From the .../iws link, there's a Documentation tab, which gets you the "Web Services Client for ILE Programming Guide", which has RPG specifics. Haven't done this myself, but looks like all of the types come in as a DS, with a null indicator in the first byte, then the actual data. Strings come in as VARYING.

Posted by: TFisher
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 23 days 17 hours 58 minutes ago

Thanks for the feedback so far guys!  I will read up on everything provided thus far. 

 

Web services is something being discussed around here for 2013 and I've been hearing discussions that lead me to believe that these projects might be given to our Java developers on our eBusiness team, yet they will have to interface with the RPG world on our iSeries.  I am tired of projects like this skipping me by.  I want to learn more ways that I can interface with RPG from the internet world.  So I am wanting to build a simple test web service that uses as much RPG as possible and runs on the iSeries to prove that RPG developers are just as capable of doing this type of work.

 

We couldn't even get the Zend PHP server installed and turned on until earlier this year.  Now that our CIO has been gone for about a year things are starting to get better.  He was so hell-bent on cramming SAP down our throats that all major projects on our iSeries were pretty much frozen.  He didn't want us learning or developing GUI, web, or mobile apps because he didn't want the business to see what we could do with their "legacy" systems.

 

Anyway, I know I have a long way to go here but I know that with the right guidance I will figure it all out.

Posted by: Ringer
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 23 days 16 hours 10 minutes ago

Dale,

For IWS, the parms are passed in like the RPG prototype parms. Java uses the PCML generated (from the RPG compile) to call the RPG via the java generated ProgramCallDocument classes buried down in the below '/www' folder.

I suppose at V6.1, the parm length is not that big an issue since you could define a parm as 16 Meg instead of the old 64K. So could pass a big XML string if wanted to.

My preference is using PHP to call RPG defined as a stored procedure that returns result set(s) via db2_pconnect / db2_prepare / db2_bind_param / db2_execute.

There's also a way to turn a PHP class into a web service in RDi but I have not played with that.

Chris Ringer

Posted by: Ringer
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 23 days 14 hours 18 minutes ago

Also most people think "SOAP XML" (WSDL wiz-duhl) when they want to consume a web service. You provide the WSDL (basically an XML config file - a "prototype" in ILE parlance) and the client tool (like PHP SoapClient() function or SOAPUI) determines the web service functions available and the format of the request in/request out XML data structure parms.

Chris Ringer

Posted by: captndjc
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 20 days 17 hours 44 minutes ago

Google CNX Corp. Valance. It's a slick tool for generating web pages with RPG as the backbone.

Posted by: TFisher
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 20 days 10 hours 8 minutes ago

captndjc,

Thanks, but I am not doing web development.  I am doing a web service.

Posted by: TFisher
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 20 days 10 hours 6 minutes ago

Ringer,

 

What I am planning to do is create my web service using the REST method first.  After that I am going to do the same web service using SOAP.  Just so I can become familiar with both types/methods.

Posted by: Ringer
Premium member *
Comment on: Web Services on the iSeries using RPG
Posted: 11 years 5 months 20 days 8 hours 32 minutes ago
Edited: Mon, 05 Nov, 2012 at 18:52:20 (4190 days ago)

Sounds good Fish. I was just cautioning against coming up with some other method such as POX (Plain Old XML) where a person has to study a Word/PDF document to figure out how to consume the web service. Programmers (client) expect a standardized document that a software tool can interrogate, like a WSDL. But of course, if you're a giant company, you can break the rules.

Chris Ringer