When .Net originally launched it came with first rate support for Simple Object Access Protocol (SOAP) and at the time I was seriously impressed. Creating a SOAP client-server connection was amazingly easy - little more than adding a .asmx file and decorating your methods with the [WebMethod] attribute, and then point your client project at it and Visual Studio does the rest.
What Visual Studio actually does in this case is create a large auto-generated code file from the WSDL. The WSDL is also auto-generated for you and is a detailed description of your service.
All great, except that it leaves you writing a complex API as part of your web project and requiring an awful lot of auto-generated code to consume it.
Enter Windows Communication Foundation (WCF). With WCF it became possible to specify a service contract – an interface that both the client and server could have that described the API. WCF also moved all description of the actual transport into configuration files – technically it became possible to write one set of code for your client and server, and then decide at run time whether to use HTTP, secure sockets, named pipes or whatever to connect.
The problem is that when I say technically I mean really, really technically: even an expert WCF programmer could end up struggling for hours to get both the server and client config to match. In addition there were only ever a few of the amazing array of options ever used: HTTP or HTTPS? GZIP compressed or not? Get any even slightly wrong would result in hard to investigate errors.
Our client software was intended to be installed and set up by users that weren’t WCF gurus. With a little help from stackoverflow.com I got an auto-config script that worked, but it was still far too much of a coding mess.
However that isn’t the biggest problem with WCF and SOAP – the whole point of SOAP is that it’s universal, an open standard based on XML that anyone can support, right?
Well, no. SOAP is vastly over complicated and the only provider with even remotely complete support for it is Microsoft. Try consuming a complex WCF (or even worse a high-security) service across SOAP from a Java client and your problems are likely to be myriad and involve many dirty workaround hacks. We had Flash components built in Flex and ActionScript that consumed WCF SOAP and found ActionScript’s support to be weak at best. Forget about anything with Javascript.
Basically, SOAP might be this powerful open standard with built in API auto-discovery, but no-one really supports it except Microsoft.
Why?
Well, it turns out that while Microsoft was getting behind SOAP everyone else was getting into Representational State Transfer (REST). The REST model is far simpler: use what HTTP already does. The HTTP protocol already has functionality to get content, upload content and make changes to it; it already includes security (in SSL) and compression (in GZIP). Why re-invent the wheel?
The downside of REST? We lose the WSDL descriptions, so no more auto-discovery and relying on Visual Studio to create everything for you. However all REST APIs are structured in the same way, so it’s usually easy to figure out how everything works.
The great thing about REST? My service can be reached by .Net, Java, Javascript, ActionScript and even spoofed with browser tools like FireBug and Fiddler.
So Microsoft backed the wrong horse. However they’ve realised this (they normally do, eventually) and have started to add first rate support for REST into both ASP.Net MVC and WCF. I'm going to investigate these new approaches, but either way I think it's time to give up on SOAP.
Add a comment