.st0{fill:#FFFFFF;}

Webservice from IBM i RPGLE program out to the web 

 December 16, 2011

By  NickLitten

So, for a recent project I wanted to create a simple webservice, a “heartbeat” program that would be written in RPG and would reply to anbody calling it from anywhere on the network with a simple response that indicated that it worked.

A webservice is routine that can be called over a TCP/IP network.

• A callable routine. (Program? Subprocedure?)

• Callable over a TCP/IP Network. (LAN? Intranet? Internet?)

• Using the HTTP (or HTTPS) network protocol

….can also be called from the same computer.

The idea is that this webservice will allow other computers on the network to communicate with our IBM i system and get a reply back sayiing “Hello, everything is hunky dory”. Tihs is called providing the webservice.

The computer that runs this servcice and gets the reply – is consuming the webservice.

I could do this using an opensource plugin like HTTPAPI (aka LIBHTTP) but this time I’m going to create it as a webservice that is called directly from the IWS (Integrated WebServer – aka IBM Apache Server)

OK – onto the nitty gritty

Configure Apache Server to make sure its ready to provide a weservice to the outside world. From the IBM i command line:

STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)

then point your browser at the this server to see if its running:

http://your-system:2001/HTTPAdmin

Create a web services Server:

Sign-in
• Click “Internet Configurations” (if IBM i 6.1 or higher)
• Click “IBM Web Administration for i”

# <NJL01> Modification Start
# WebServices added for ACSIS

ScriptAlias /info /qsys.lib/nlitten.lib/webinfo.pgm
ScriptAlias /valbin /qsys.lib/nlitten.lib/webvalbin.pgm
ScriptAlias /getbin /qsys.lib/nlitten.lib/webgetbin.pgm

<Directory /qsys.lib/nlitten.lib>
Order Allow,Deny
Allow From All
</Directory>

# </NJL01> Modification End

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!

>