For a recent project I had to connect to two different read-only web services. Both were from commercial vendors providing very similar information (which I aggregated). One API was REST based the other used SOAP. The REST interface took me a few hours to write, the SOAP one took days!
For the REST interface I had to send requests to a URL that somewhat indicated what I was attempting to do – eg http://example.site/contracts/123 to get the details of contract with id 123. An XML was returned and using a SAX parser constructed my internal objects. In total it took 340 lines of my code to handle the entire web service. Easy!
Using the SOAP interface required me to download their WSDL and then construct a model of their domain objects – I used Apache Axis2 (not Apache Axis though, that is an old and unmaintained project that does the same thing – a confusion that cost me some time). Unfortunately the WSDL was wrong and the model didn’t generate properly. I had to dive into the 2000 line WSDL file to find and fix the error – and it was near unreadable! Try looking at a commercial WSDL file some time. After some trial and error the model was right and when surrounded by copious error handling code it could be sent and data received from the service. It took 810 lines of my code, plus hundreds more in the generated model. Urgh. At this point one might suggest it was just a problem caused by a dodgy service provider. However, I have since added a third read-only web service to the project. It is also SOAP based and just as difficult to get running properly – apart from having to modify the WSDL since theirs was correct from the start.
I also have experience from the other side, providing a web service. Using Ruby on Rails I added a REST interface to my existing website by just providing XML views of the data. While working at a bank a SOAP interface to an existing legacy system was required, it took a great deal of fiddling and trust in our IBM development tools to get it working after a couple of days.
The experience reminds me of an interview on The Register where Tim O’Reilly suggests that SOAP is a standards first specification created without reference to how it would be used in the real world (because at the time the spec was created there weren’t any people using it). SOAP definitely feels like an overengineered solution. The kind of thing I would have loved earlier in my career when suffering from Second System Syndrome. Over time I am becoming increasingly appreciative of simplicity in code.
For me, there is now no comparison. SOAP just doesn’t seem to work well in any place I’ve seen it tried. My first choice for web service API will have to be REST.