There’s been a lot of jazz about RESTful services, which was published to the masses by a person named Roy Thomas Fielding in his PhD dissertation. Since then, RESTful services have been embraced and widely used. To name a few, Twitter and Facebook exposes RESTful web services API to us to consume. I shall not go into the principles and concepts of REST, but I personally find RESTful services to be very natural, easy to understand and it just flows with how the World Wide Web works, which is driven by the HTTP protocol. You can learn more about RESTful principles from wikipedia, or just google it. It’s very much the opposite of using SOAP, which has been the Microsoft way for some time now, but in .NET 3.5, REST has found its way into WCF.
Now back to business, let’s talk about how to create a RESTful service using WCF. If you search google, you will find heaps of examples how to do create WCF RESTful services, but there’s been very little information out there about how to consume it. I found some examples about using WCF ChannelFactory and generating a client proxy to consume the WCF RESTful service, but I feel these approaches violates the whole point of using REST. In order to consume a RESTful service, regardless of how it’s hosted, we should just consume it using simple HTTP requests generated from code. In this post, I will show you how to create, host and consume the services with WCF and the .NET framework.
Read the rest of this entry »