WCF Tutorial
www.Learn2Expert.net A new ASP.Net MVC 4, SSIS, Interview Q/A tutorial - Visit - www.Learn2Expert.net
Skip Navigation LinksHomeRESTful Service No of Views: 79928

Introduction to RESTful service

REST – Representational State Transfer

"REST, an architectural style for building distributed hypermedia driven applications, involves building Resource-Oriented Architecture (ROA) by defining resources that implement uniform interfaces using standard HTTP verbs (GET, POST, PUT, and DELETE), and that can be located/identified by a Uniform Resource Identifier (URI)."

Any Service which follows this REST architecture style is called as RESTful service. It became very popular because of it behavior, it is similar to the website i.e we can load the server information using web url in the browser. similarly we can also access/modify the server resource using Url in RESTful service

  • RESTful service will allow the client (written in different language)to access or modify the resource in the server using URL.
  • RESTful service uses the http protocol for its communication and it is stateless
  • RESTful service can transfer the data in XML,JSON,RSS,ATOM
SOAP POX(plain-old XML) REST
  • Simple Object Application Protocol
  • SOAP – is a package contain message information and it will be delivered by HTTP
  • Developers are mainly preferred to user because of its increase interoperability
  • Lot of tools are available in the market to generate the clients code from WSDL
  • Plain raw XML message will be used for communication
  • Developers using POX had to write their own code for XML and HTTP for request/response message.
  • So most of the developers moved back to SOAP
  • REST defines more of a transport-specific model
  • In reality HTTP is the only protocol that is used in practice today for building RESTful architecture.

This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods. According to this mapping

  • To create a resource on the server, use POST.
  • To retrieve a resource, use GET.
  • To change the state of a resource or to update it, use PUT.
  • To remove or delete a resource, use DELETE.

RESTful service can be created by using WebGetAttribute and WebInvokeAttribute attribute. RESTful service has provided separate attribute for GET operation (WebGet) because it want to make use of complete features. Other operations like POST,PUT,DELETE will come under the WebInvoke attribute.


  • Always create the service with Interface->Implementation format, mention the contract in Interface.
  • Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
  • Change the instance mode to per call as default.
  • Always catch exception using try/catch block and throw exception using FaultException < T >.
  • Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.