One of the announcements that was kinda missed at PDC was the release of the WCF REST Starter Kit. In brief, the REST Starter Kit provides a was for developers to “jump-start” the development of REST services in WCF.
The Premise
In .NET 3.0 WCF allowed developers to abstract the way a service communicates with the world from the way the functionality of the service was implemented. Developers designing services in a “contract first” manner were able to specify minimum requirement and rules for their services. Provided that the communication medium (transport and binding) was able to provide the service with the facilities that it needed, that service could be invoked via that medium. For example, a service could expose both HTTP based and TCP based endpoints without having to change the functionality of the service. In WCF there is not a concept of a “web service”: there are just services. Some are available via HTTP over the web.
WCF also provided developers with ways to customize and extend the way the service communicated and behaved at runtime via custom channels and custom behaviors.
What it didn’t do very well was provide a way for developers to easily create REST based services. But that changed with the release of .NET 3.5. Using the WebGet and WebInvoke attributes in the Service Contract gave developers a way to write REST services in WCF
The Problem
For all it’s power, configurability and extensibility WCF has always had a bit of an image problem. Most developers view it as difficult to work with, difficult to understand and tied to a obnoxiously verbose configuration model. The inclusion of REST abilities in 3.5 did nothing to help do away with this perception.
The Solution
Enter the WCF REST Starter Kit. The Starter Kit provides a set of templates for creating a variety of REST-based services including Singleton Services (exposing a single resource on the server), Collection Service (exposing a list of resources/data), POX Service and projects for ATOM feeds and ATOM publishing protocols. The starter kit also comes with a new assembly called Microsoft.ServiceModel.Web which contains an API the provides a lot of out-of-the box functionality to support REST services including customized help pages, customized caching, easier ways to return exceptions, URI templates, and the ability to use request and response headers.
The long and the short of it is that you select a project template based on what kind of service you want to write and then add the appropriate functionality to a few methods and bang, you’ve got a service.
The Good
The starter kit comes with templates for most kind of REST based services you will need to write. While a basic knowledge of REST and how routing works (if you’ve done any significant MVC work you’ll be fine) you can get a REST based service up and running in a matter of minutes with data represented as both XML and JSON. Little real WCF knowledge is required to simply get a service up and running.
The API extensions will offer something to those more experienced with WCF by providing a means to perform some customization without having to write a custom behavior or channel.
The Bad
It started with the install. Part of the starter kit is a bunch of Visual Studio content. The installer kept giving me a Null Reference Exception. I found a workaround here.
The classes created by the starter kit are designed for ease of implementation, not for extensibility. Customization involves a lot of friction. If you need to do anything beyond a basic REST implementation you will need to acquaint yourself with the object model that the starter kit uses, which can be a little overly complex. If you need to do complex routing or create a service to provide more than one data type you’ll need a level of knowledge about REST in WCF that the start kit is supposed to insulate you from.
Another issue I’ve encountered is that when I try to rename the Service.svc file in the project generated by the Starter Kit I get an “… operation not completed. Unspecified error.” error.
In the End
I’m in favor of a REST Starter Kit, or ANYTHING for that matter that increases adoption of WCF. I think the Starter Kit is a good late-beta/1.0 release, but it’s got a ways to got before I consider it a major part of my tool-box.
Code On!
Print | posted on Monday, December 22, 2008 8:53 PM