The new WCF Web Programming Model supports REST Design
Don Box and Steve Maine introduce the WCF Web Programming Model to be released with Visual Studio Orcas in their talk "Navigating the Programmable Web" at MIX07. The Web Programming Model features support a RESTful design of web services within the unified WCF programming model.
The new features are intended to help programming simple services that do without a SOAP envelope or any WS-Specs. Instead the Web Programming Model centers on URIs and the HTTP verbs. In order to maintain the WCF programming model, the ServiceContract, DataContract and all other Service Model aspects of WCF are still used. The new model manifests itself mainly in a new WCF Service Host, called WebServiceHost, and a new standard binding: WebHttpBinding. The new features consist of:
- Support for URI templates by the System.UriTemplate. A URITemplate is used to defined a specific pattern of URIs. The idea of URI templates is described by Joe Gregorio in his blog entry.
- System.UriTemplateTable, which is used for storing a set of UriTemplates that can be matched against a concrete URI in order to find the best match.
- [WebGet] and [WebInvoke] attributes for service operations, which are used by the WCF dispatcher in order to map an HTTP request to an implementation method.
- WebServiceHost and WebHttpBinding.
- System.ServiceModel.Syndication namespace, which adds support for producing and consuming RSS/Atom feeds.
All features are explained in detail in Steve Maine's series on the Web Programming Model: Zen of the Web Programming Model (Part 1), Zen of the Web Programming Model (Part 2), Zen of the Web Programming Model (Part 3), UriTemplate 101, and UriTemplate.Match.
So, it is interesting to me to watch guys like Clemens Vasters and Don Box (and Steve Maine, though I think he was less heavily involved in 'expectorating' the WS-splat and a lot more heavily involved in consuming and evangelizing prior to getting into the big house) starting to shed the WS-Splat baggage and just GET it. And I think that they are being pragmatic about it and trying to scratch the 80% itch (GET) really well, but they are adding in a decent set of support for the REST (ha, pun, ha ha, er, um...) of the story without being to religious about being RESTful. And when questions come up like [paraphrased] "Well, shouldn't you layer soap into that?" they look very relaxed and calm as they say [paraphrased] "Nah, you're not going to need it here." From the outside, it looks a little cathartic.
David Ing calls the talk the Simple Object Apology Protocol, because "after all that work and code put into SOAP based infrastructure and programming models, [the Web Programming Model] is essentially a 'roll-back' of the application protocol stack back to around 2002.". He also points out some risks of adding a new model to the WCF stack:
One big problem with the 'add an alternative layer, now we know' approach is that many developers equate the latest technology update to mean the latest guidance on what to use for their problem. [...] By having such a broad choice of what to use (REST, HTTP/POX, SOAP, Remoting etc. etc.) then for the people looking for the 'one simple answer' it just gets increasingly complex and confusing. The complexity tax of these news things are start to look like the federal deficit - always going the wrong way.
Steve Maine responds to these two reactions by stating that WCF is essentially "Balancing reach and rich":
As such, I think the reach programming model work we're doing now actually increases the value of the rich protocol stack in V1 because it gets rid of the traditional scenario cliff between rich and reach. Take a framework like Rails, for instance - which is optimized around making a common set of scenarios very easy. Granted, the stuff Rails optimizes for hits the 80% case. But if you suddenly have to step into the other 20% for whatever reason, you're kind of screwed (as the Twitter guys are finding out). We want to protect folks who take a bet on WCF from falling off similar cliffs in the distributed systems space. We're taking a big step in that direction with the Orcas Web features, and you can expect us to continue down that road over time.
The Web Programming Model is another step of consolidating the programming models of all known protocols and ways of developing distributed applications within WCF. It is also one of many signs that Microsoft is really fond of the REST way and incorporates REST designs in their project portfolio today: The Astoria Project is already based on the new model.