Recently I was doing a review of some .NET 3.5 WCF REST code based on the REST Starter Kit to see what it would take to move it to .NET 4.
The more I looked at the code and thought about it deeply I realized that the mechanics of exposing a service over HTTP are not the hard part. What is difficult is to get the semantics of HTTP right. After spending some time reading through the HTTP spec I took a stab at creating the Canonical REST Entity Service
“ca·non·i·cal [ kə nónnik'l ] conforming to general principles: conforming to accepted principles or standard practice'”
What I was after was a set of requirements that I could verify about the way in which a REST Entity Service should behave. Here is what I came up with.
First of all I learned that Canonical is spelled with 1 n and not two as in “Cannonical” [sic] which I used all over the place in this code so… sorry.
Canonical REST Service (MSDN Code Gallery)
Finally, my favorite WCF REST solution is getting some well deserved love!
Thank you!
I wonder what the RESTful bigots will say about this?
@DaRage - well I hope we can dialog about it and make it better. I'm actually trying to build something that is faithful to the ideals of REST.
Thanks for your work on this project. It would be nice to see a fully supported WCF REST template for Visual Studio 2010 and ASP.NET 4.0 from Microsoft that just works "straight out of the box" for both both development server and production server. The WCF team has been working on WCF for how many years now? And there's still no easy to use implementation of REST in WCF with a Microsoft supported template for REST in WCF?!? Even after all these years of WCF?!? So why should we bother to use WCF for REST? Why not just use ASP.NET MVC? It seems to me that the MVC team is doing a much better job than the WCF team in building a framework that supports REST style programming for the web? Maybe your work on this current project of yours will lead to a fully supported template for REST in WCF. If so, then there needs to be a clear and compelling demonstration that WCF is not going to cause the headaches that it has caused for the past several years...
I hope so too Ron. However, I have an opinion that I would like to voice here about REST and WCF. I think, and I'm sure you heard that before, that RESTifying WCF is changing it to something that it was not designed for, in other words, bastardizing it.
The foundation of WCF of decoupling from transport and ABC simply don't apply to REST and adjusting WCF to be RESTful would work but it will not be simple. Because one of the main driving forces of REST is simplicity i think this approach will have limited success. I speculate that the effort of unifying WCF and REST is more driven by business needs than technological ones and because people who do REST are such technological bigots as I mentioned this thing will not fly with them.
I think that creating a parallel RESTful WCF and WF frameworks from scratch will be much simpler and leaner and maybe they will become the dominant one framework int the future.
@DaRage - Just wait - the team is working on some really cool new stuff for REST that will give you what you are looking for (I hope).
What do we need to install to open this in Visual Studio 2010. A pristine install of VS 2010 Premium says the project type is not supported.
@VS2010 Compatible... I'm not sure wht the issue is. It is just a Web Project, a Test Project and a Class Library project. Nothing unusual there.
DaRage - I agree with you, and your remarks seem to echo my concerns that even if the WCF team might be trying to RESTify WCF, at least in my opinion, they are not succeeding in a coherent and fully supported manner that builds confidence. So then if RESTifying WCF is not the preferred approach, should there be a RESTified MCV with full tooling/testing support for RESTful programming? Or should it be a new framework entirely devoted to REST and only REST?
ronjacobs - Is the really cool new stuff for REST built on top of WCF, on top of MCV, or as discussed here, completely independent of either WCF or MCV?
@DaRage - The new stuff is new stuff :-)
What really matters is what it does and how it works. When the time is right (hopefully soon) we will begin sharing it with you on Codeplex to get your feedback.
My first goal will be to update this sample based on the new stuff - that is why I built the tests - they will be a good barometer for insuring the new stuff is really working as it should.
@DaRage, @Carl
Thanks for all the feedback. I am driving our HTTP/REST story going forward. I hear all your concerns. We are not looking to simply retrofit on top of our existing stuff. We are looking at a pure resource oriented model, and how to best deliver on that. That doesn't mean we won't use some of our existing bits, but we are really focused on the ideal experience over how can we just use what we have. We're also focused heavily on involving the community both inside and outside of .NET in the work we are doing. This includes getting source out there sooner which is something we're working on.
I have posted early thinking on this here: codebetter.com/.../resting-from-mef-or-the-mef-dealer-is-at-rest.aspx
I'd be happy to chat with either of you more to hear your concerns.
Thanks
Glenn
So this isn't SOAP or OData, but this returns XML of a Resource type. Also this is NOT WCF Data Services but looks like WCF Services. NOW I am confused as what to use.
@Allan - Hang on - we are mixing things up a bit. What I built is based on WCF WebHttp Services with stock .NET 4 and a set of tests that can verify a service behaving correctly.
What Glen is talking about is next-gen stuff