AS400 or iSeries webservices – Primer
If you are reading this it’s probably because you are researching webservices, perhaps looking for an IBM i Webservices Primer and googled something like “what is the difference between SOAP and REST on IBM i webservices – please help me I am going insane“? http://bfy.tw/9ON0
Dont worry – help is at hand. But you might still be insane!
Simple Object Access Protocol (SOAP) and Representational State Transfer (REST) are two different, but similar, ways of talking to Web services out there in Internet Land.
What is SOAP?
SOAP is the long established and much used standard for webservices. It communicates using XML and was originally designed by Microsoft. If in doubt, SOAP is an easy place to start when looking at webservices, but bear in mind that older does not necessarily mean better.
Simply put, SOAP uses XML and a WSDL specification to handle it’s conversations. When Microsoft originally created the SOAP protocol it was to replace older technologies that didn’t understand the Internet — things like Distributed Component Object Model (DCOM) and Common Object Request Broker Architecture (CORBA). Older technologies use binary messaging to talk to each other but building a layer between applications talking with XML messaging lets different systems easily communicate over the internet.
What is REST?
If SOAP is more verbose than REST – so why do I say it can be easier to use?
Because the wonderful IBM i Power System has a great integrated webserver (commonly referred to as the #IWS) which handles all the webservice XML & JSON conversions for us… but more on that later.
Should I use REST or SOAP?
Hmmm – this is the six four thousand dollar question.
SOAP is the established player in the world of Web service internet access.
- More verbose than REST but XML is easy for humans (aka programmers to read)
- Language, platform, and transport independent (REST requires use of HTTP)
- SOAP can be used in batch style environments because it uses XML format and not point-to-point
- The WSDL offers nice error handling and data validation before the XML data even gets to your webservice program
- XML is easy to use with RPG programs (a big bonus for us RPG ILE Programmers)
After saying all that – REST is easier to use because of it’s short form and it might require less programming work.
- REST has a smaller learning curve than SOAP (JSON is just as easy as XML really)
- It’s smaller so its faster (SOAP uses XML for messages, REST uses JSON which is a less-verbose message formats)
- a more modern standard that is growing rapidly
Personally – I would recommend start with REST and JSON. Get a feel for it. Play with the Integrated webservice and learn XML Play with SOAP and REST services and see which one floats your boat.