Thoughts on the WCF REST Starter Kit

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!

kick it on DotNetKicks.com
Print | posted on Monday, December 22, 2008 8:53 PM

Feedback

# re: Thoughts on the WCF REST Starter Kit

left by Bart Czernicki at 12/24/2008 1:27 AM Gravatar
I like the WCF REST Starter Kit for a good understanding as to how Microsoft is thinking.

I really like the fault -> Http Status code exceptions (that works really well for clients that can't handle true WCF faults like Silverlight or Ajax).

I 100% agree with you that, there is no way you can add the Starter Kit to any kind of production code. However, it was announced that the Starter Kit will be part of the WCF 4.0 framework so getting to know the baseline is always a good idea.

We'll know more when the March CTP of VS 2010 comes out :)

# re: Thoughts on the WCF REST Starter Kit

left by Anand at 1/13/2009 8:56 PM Gravatar
The install issue you mention used to occur only when you specified "For Everyone" in the install. The installer was updated to remove that option entirely and reposted on December 9th 2008. If you install it now, you will see that the issue will not occur. See the related post at http://forums.asp.net/t/1358692.aspx.

Thanks
Anand

# re: Thoughts on the WCF REST Starter Kit

left by Four Card Poker at 7/14/2009 3:53 AM Gravatar
Great labs. They helped out a lot. Lab 4 however has some things that don't match up. The tests are expecting a WebProtocolException but only CohoWebException ever gets thrown. I looked at the code to see what was going on considering that it may have been my machine messing things up. Turns out the only exception ever thrown is the CohoWebException so I found and replaced all occurances of WebProtocolException with CohoWebException. With this change anywhere webx.StatusCode appeared StatusCode needed to be changed to Status (i.e. webx.Status) After that smooth sailing. Thanks for the introduction to REST.

# re: Thoughts on the WCF REST Starter Kit

left by campionato europeo di Poker at 10/14/2009 7:06 AM Gravatar
I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.Any way Ill be subscribing to your feed and I hope you post again soon...

# re: Thoughts on the WCF REST Starter Kit

left by IT Support at 3/9/2010 4:15 AM Gravatar
Nice post.I like the way you start and then conclude your thoughts. Thanks for this information .I really appreciate your work, keep it up

# re: Thoughts on the WCF REST Starter Kit

left by web designer croydon at 3/9/2010 5:05 AM Gravatar
I wanted to thank you for this excellent read!! I definitely loved every little bit of it.Cheers for the info!!!!

# re: Thoughts on the WCF REST Starter Kit

left by Miami Web Design at 3/9/2010 5:05 AM Gravatar
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

# re: Thoughts on the WCF REST Starter Kit

left by SEO UK at 3/9/2010 5:06 AM Gravatar
I found your website perfect for my needs. It contains wonderful and helpful posts. I have read most of them and got a lot from them. To me, you are doing the great work. Carry on this. work at home In the end, I would like to thank you for making such a nice website.

# re: Thoughts on the WCF REST Starter Kit

left by Printer Ink at 3/9/2010 5:07 AM Gravatar
Do you always write this stuff, over you head.. Great article! Tell me more, let it come.. You are master. :D

# re: Thoughts on the WCF REST Starter Kit

left by A1 Guaranteed Website Traffic at 3/10/2010 4:16 AM Gravatar
Provides genuine and guaranteed real human worldwide and country targeted unique visitors for your website. Very affordable traffic packages available.

# re: Thoughts on the WCF REST Starter Kit

left by Webdesign solutions at 3/10/2010 4:58 AM Gravatar
Wedesign, graphic, hosting solutions and programming resources

# re: Thoughts on the WCF REST Starter Kit

left by e-Commerce Solutions at 3/11/2010 10:41 AM Gravatar
We give you more value for your online investment in web design, web building and E-marketing, as we are an all inclusive web solution.
Title  
Name
Email (never displayed)
Url
Comments   
Please add 3 and 7 and type the answer here: