ASP.NET, Coding

What is REST (Representational State Transfer)

Governing Principles of REST
Since REST is a vast topic by itself, I’m not intending to elaborate on the intricacies and nuances of it here but would like to skim through its basic governing principles. They are:

  • Clients (user agents) interact with resources. Resources are anything that can be named and represented. Each resource can be addressed via a unique URI.
  • Interaction with resources (located through their unique URIs) is performed through the standard set of HTTP verbs (GET, POST, PUT or DELETE) along with the declaration of resource’s media/MIME type (JSON, XML, XHTML, JPG, PNG etc).
  • Resources are self-descriptive. Each request on a resource contains all information necessary to process that request enabling the services to act as stateless.
  • Resources can contain links to other resources (hyper-media). If the client wants to access related resources, they should be identified in the representation returned.

REST and Microsoft
Microsoft is moving many of its own implementation away from RPC technologies such as SOAP and has started embracing REST in the recent years. Microsoft’s WCF architecture has been designed with the capability to expose and consume RESTful services from its release with Framework 3.0. An easy-to-work-with REST programming model (WebServiceHost, WebServiceHostFactory, WebGetAttribute, WebInvokeAttribute, WebHttpBinding, WebHttpBehavior, UriTemplate etc) was added with Framework 3.5 mainly to support AJAX calls. Much more enhancements are expected in the forthcoming releases. Microsoft has also come up with a ‘REST Starter Kit’ to make REST based WCF development easier.

Microsoft’s ASP.NET MVC also gives full control of creating RESTful services with a little bit of plumbing code. ASP.NET MVC Controllers can directly return objects and collections, without rendering a view, which makes it quite appealing for creating a REST like API. Depending on who is calling the service, you can return JSON, plain old XML and so on.

Microsoft’s .NET Data Services Framework (code name Astoria) also provides a roadmap on how REST type Web services will be designed and deployed in the Microsoft world.

REST is an architectural style but neither a standard nor a toolkit. It’s a refined version of what web already has. REST may not be the best choice always. However, we cannot ignore it considering the current industry trends and its benefits. Hopefully REST will be able to resolve the shortcomings of today’s SOAP based systems.

You Might Also Like