What is RESful service and designning RESTful service using ASP.NET

REST stands for Representational State Transfer.  REST is an architecture style for designing networked applications.  RESTful applications use HTTP requests to post data (either insert or update), read data, and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.  REST is a lightweight alternative to RPC and Web Services (SOAP, WSDL, etc..).  It is common convention in REST design to use nouns rather than verbs to denote simple resources.

How REST is different than SOAP Web service?

SOAP relies on application layer protocol like HTTP.  HTTP request and HTTP response is wrapped in SOAP envelop that is trasmitted over HTTP channel.

Here is the typical SOAP request looks like.

<?xml version=”1.0″?>
<soap:body pb=”http://www.patelshailesh.com/feeds”>

Here  is RESTful API request looks like.

This is just a URL and can be requested using a simple HTTP GET request which returns all feeds data in XML or JSON or any expected format.  Although other information can be passed through HTTP Post header too.

Here are some RESTful API benefits (over Web service)

  • is lightweight
  • is easy to call
  • is easy to parse response which easily machine readable
  • Saves bandwidth (because of reduced HTTP request and HTTP response size)
  • HTTP request and HTTP response can be in any format like XML, JSON, csv, binary
  • Supports verbs that defines action like GET, POST, PUT, DELETE.
  • Exposing services using RESTful API can make it easier to integrate functionality with a broad variety of device and client plateforms.
I would encourage you to read below article for more detail about REST.

What are the options to design RESTful service in ASP.NET?

1) WCF REST service
WCF can be configured to support RESTful Service.  Even WCF can be configured to support multiple format SOAP and JSON so you DON’T need to write multiple methods to support both SOAP and JSON.  You can also configure multiple endpoints(SOAP and REST) for same service so that service can be exposed as SOAP and REST both.
Here are some useful links if you decide to go with WCF REST service.


ASP.NET MVC is resource-oriented NOT html-oriented because controller decides how view is rendered.  You can consider controllers as services and use the MVC infrastructure to define the control requrest, responses and better control the HTTP message.  ASP.NET Web API is borned from ASP.NET MVC and which is now another template of ASP.NET MVC project.


It used to be known as WCF Web API back in time which branched out to standalone ASP.NET Web API framework to support RESTful service.  ASP.NET Web API is designed to support mainly REST.  You can still use WCF for REST support but it requires lot of configuration to support REST.  If your need is only to support REST, I would say you should go with ASP.NET Web API.  If you want to create services that can use transport channels when available such as TCP, UDP or need support for SOAP service as well, you can go with WCF.
Below article discuss about how ASP.NET Web API borned and when/why to use ASP.NET Web API versus WCF REST service.

Other useful links for ASP.NET Web API

4) Open source frameworks such as OpenRasta and ServiceStack

Hope this helps.  If this post really helps you, please click the Google +1 button to show it really helps you save your time.
Posted in Microsoft Technology Tagged with: , , ,