What is Rest Service in WCF – Easy WCF
Skip to content

What is Rest Service in WCF

What is Rest?

Representational state transfer(REST) is an abstraction of architecture of world wide web. REST is an architectural style to design networked application.REST makes communication between remote computers easy by using the simple HTTP protocol which support for CRUD (Create, Read, Update, and Delete) operations on the server

Why Rest?

For an example, you have to build a Web Service which should be cross functional and should be able to be consumed by any client. Traditional Web Services in .NET have to be consumed using a proxy. What if the client does not know how to create a proxy?

RESTful web services uses HTTP directly:

  • No RPC layer like SOAP or XML-RPC
    • it uses the infrastructure of the Web as it was designed to communicate between client and server
    • Designed to scale
    • Little or no middleware required
  • Main abstraction is Resource not type
    • Resources have uniform interfaces,no negotiation of type interface
    • Servers are stateless

REST is layered:Interactions are uniform across network layers

  • Clients don’t know whether they are communicating with end servers,proxies or gateways
  • Components can be independently deployed to improve performance and enforce security

 

REST constrains itself to a uniform interface.

  • All operations have well known semantics
  • Most operations are either safe or idempotent
    • Safe means the operation has no side effects
    • Idempotent means the operation can be performed multiple times without changing end result
  • Responses state whether the resources are cacheable.

Difference between Rest and SOAP services:

  • REST is simpler to program than SOAP
    • Retrieval consists of a URL(GET)
    • Creation consists of a URL(POST)
    • Update and Delete also simple (PUT,DELETE)
  • SOAP semantics are opaque, so it bypasses the features of layered internet
  • REST is lightweight on the client side
    • you need to write a little bit of script codeand you are off and running
    • Javascript frameworks make it browser independent and easy to integrate
  • REST is lightweight in server side
    • you need to write a little bit of script codeand you are off and running
    • Frameworks support the web servers

 

Difference between SOAP and Rest services:

  • It is easy to get REST wrong
  • SOAP tool suite is bigger
  • SOAP offers type safe and formal contracts
  • Web services stack includes integrated middleware standards those are useful for security,reliable messaging etc..

 

What is in a RESTful webservice design?

  • A set of resources
  • URLS for your resources
  • The operations you wanted to perform on those resources
  • The set of representations for those resources
  • from server to clients
  • from clients to server

 

Uniform Interface style:

  • Operations on the base URI affect the set of resources as a whole
    • GET lists them
    • POST adds a new resource to the set
    • DELETE deletes the whole set
    • PUT replaces the set with a new set
  • Operations on an ID-qualified URI affect an individual resource
    • GET retrieves it
    • DELETE destroys it
    • PUT replaces it or create if doesnot exists

 

Resource URLS:

  • The service has a base URI that represents whole set of resources
    • ex: easywcf.com/posts
  • The base uri can be qualified with an identifier specifying an individual resource
    • ex: easywcf.com/posts/1053
  • RESTful services are hierarchical, resources offered by one service can contain more service

© 2015, admin. All rights reserved.

One thought on “What is Rest Service in WCF

  1. Pingback: Five steps to create a WCF Rest service | Easy WCF

Leave a Reply

Your email address will not be published. Required fields are marked *