A Web Service is a program that talks to *something* on the WEB.
You might be asking yourself “What is a webservice?” or “What is an AS400 webservice?”. First of all, I am not going to rant about how its not an AS400 webservice, nor is it an iSeries webservice — it’s an IBM i webservice. IBM dont make the old AS400 and iSeries machines anymore, so stop calling the IBM i System that #endofmessage.
Anyway, lets look at what a webservice is and perhaps do a quick, high level overview to explain the basics.
How does an IBM i Server talk to the Internet?
Here is a question frequently asked in IBM i programming forums:
How do I write (an IBM-i program) RPG, to talk to the internet and receive or send parms to a website or webservice? For example, how can I receive an order number and return the order line information in XML?
Sounds kind of complicated, doesnt it?
Special Offer for all NICKLITTEN Punters
20% Off with Coupon: NICKLITTEN
In Partnership with SNUG CBD - American readers get 20% off
CBD helps with relaxation, focus and great for pain relief. I highly recommend the SNUG CBD Tincture to help keep you in the zone when programming!
Actually, its not 🙂
Luckily for us, this is an area where the bods at IBM have implemented a really cool server on our beloved IBM I operating system that makes this process so simple, it’s really quite astounding. All we have to do is write a program that does the business logic (for example, receive an order number parameter, read the order line details and return those parameters back). Then we can simply use the IWS* (Integrated Web Server) to share that information with the world wide web.
- NOTE: the IWS happens to be the APACHE SERVER. But I guess this could change at some point in the future so I’m going to call the IWS rather than the Apache Server.
The IWS is easily used from any web browser that can talk to your IBM i Server and it has a very simple wizard that will create a webservice from your RPG program. Not only that, but it will automagically create a WSDL*, and deploy the webservice to its application server. The IWS is free and comes automatically with the system.
There are lots of ways to do this and its much easier than you may think.
*What is the IWS? The integrated Web services server for IBM i enables the deployment of ILE-based program objects as Web services. The IWS is free and comes included with IBM i you simply need to start the server and start using it.
*What is a WSDL? A WSDL is an XML document that describes a web service. It actually stands for Web Services Description Language.
*What is SOAP? SOAP is a technique that lets you exchange info over a particular protocol (can be HTTP or SMTP, for example) between applications.
*What is a XML and JSON? Think of these as the language of the webservice. Webservices write their messages in JSON or XML so that the program (or browser) the other end can easily read what they are sending or receiving over the web.
Don’t get scared by all the buzzwords like server, serving, consuming, publishing, soap, rest, xml, json…. take a deep breath and dont panic.
If this is the first time you have written a webservice, or if you just want to see some alternative RPG code examples then look at these blogs
Does this make sense? Still with me? Then lets read a Primer on Webservices