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:Envelope
xmlns:soap=”http://www.w3.org/2001/12/soap-envelope”
soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”>
<soap:body pb=”http://www.patelshailesh.com/feeds”>
<pb:GetFeeds>
</pb:GetFeeds>
</soap:Body>
</soap:Envelope>

Here  is RESTful API request looks like.

http://patelshailesh.com/feeds/
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.

2) ASP.NET MVC

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.

3) ASP.NET Web API

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.
Tagged with: , , ,
Posted in Microsoft Technology

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
Ads
OutbackDirect.co.uk is a trading site of World of Power.co.uk Limited. Outback Direct is the official Outback Consumer Warranty, Parts and Accessory Partners for the UK. We currently hold in stock 1000’s of parts and accessories for current and older Outback barbecues. We endeavour to ensure rapid and secure product delivery the length and breadth of mainland United Kingdom, this factor coupled with our excellent customer service has led to the market position we currently enjoy.
outback barbecue
omega 300 gas barbecue
Omega 250 Gas Hooded BBQ
------------------------------------------------------------ Silver Sky Imports is a unique online marketplace that offers unique handicrafts from Tibet and Nepal. Launched in 2003, Silver Sky Imports is currently the largest supplier of handmade items from the Himalayas. We specialize in the largest variety of Tibetan Singing Bowls and Crystal Singing Bowls online and include individual sound samples, pictures and descriptions for each bowl. Some of our other products include Tibetan Prayer Flags, Tingshas, Bell and Dorje, Incense, Felted Wool Handbags, Wood Masks, Prayer Wheels, Gongs, Bronze Statues, and Tibetan Meditation Rugs. monks
------------------------------------------------------------ Airpush, a mobile ad network that is only two years old, has quickly grown to one with over 5,000 advertisers. One thing they've heard from that sea of advertisers over the past 12 months, and especially over the past six, is that real-time bidding (RTB) capabilities are now a must. To answer those needs, the company today unveiled AirDSP, a platform meant to easily connect advertisers to RTB exchanges. Read more: Mobile RTB
------------------------------------------------------------ Danish site about electronic cigarettes E Cigarette, Electronic Cigarette and E Cigarettes e cigaret
------------------------------------------------------------ DrugRisks.com drugrisk​ recall ​informat​ion​ drugrisk​ yaz​
------------------------------------------------------------