Overview of RESTful Services in ASP.Net

These days it is a very common buzz word and most developers have definitely heard about this.

Before beginning to describe REST services let's first look at services.

Services

  • A service is a self-contained unit of software that does a specific task.

  • A service is a reusable component.

  • A service changes business data from one state to another.

  • If you can describe a component in WSDL, it is a service.

Types of Services: There are two types of services.

  • Big Web Services
  • REST Services
Big Web Services

Big web services are based on the SOAP standard and often contains a WSDL to describe the interface that the web service offers. The details of the contract may include messages, operations, bindings and the location of the web service.
  • Address
  • Binding
  • C-Contract

REST Services

RESTful web services are based on the way the web works. REST is neither a standard nor a protocol. It is just an architectural style, like say for example a client-server architecture. It's based on HTTP.

The term Representational State Transfer was introduced and defined in the year 2000 by Roy Fielding during his PhD research programme. REST has been applied to describe desired web architecture, to identify existing problems, to compare alternative solutions and to ensure that protocol extensions would not violate the core constraints that make the web successful.

Resource-Oriented Architecture (ROA)

Since you have heard about Service Oriented Architecture (SOA) but REST Services are based on the Resource-Oriented Architecture (ROA).

Resource-Oriented Architecture (ROA) is a style of software architecture and programming paradigm for designing and developing software in the form of resources with "RESTful" interfaces. These resources are software components (discrete pieces of code and/or data structures) that can be reused for various purposes.

Features of Resource-Oriented Architecture (ROA):

  • Addressability: Addressable applications expose a URI for every piece of information they might conceivably serve.

  • Statelessness: Statelessness means that every HTTP request happens in complete isolation. The server never relies on information from previous requests.

  • Connectedness: A Web service is connected to the extent that you can put the service in multiple states just by following links and filling out forms.

  • A uniform interface: Resources should be called using HTTP Verbs (get, post, put and delete).

Benefits of Restful Services

  • Platform-independent.
  • Language-independent.
  • Standards-based (runs on top of HTTP).
  • Limited bandwidth and resources.
  • Totally stateless operations.
  • Caching.
  • Reaches more clients (mobile, tablet and so on).
  • Lightweight hosting and scalable with Cloud.

HTTP Verbs used in REST Services

  • GET: Retrieves a resource or resources.

  • POST: Adds a resource.

  • PUT: Updates a resource.

  • DELETE: Deletes a resource.

SOAP vs. REST

Issue in SOAP

Resolution in REST

In SOAP along with data many other metadata also needs to be transferred with each request and response. This makes the payload heavy even for small data.

only the data will be traveling to and fro from the server because the capabilities of the service are mapped to the URIs and protocols

In SOAP there is a need to create the proxy at the client side. These proxies will do the marshaling and un-marshaling of SOAP WSDL and make the communication between the application and the web service possible. The problem with this proxy is that if the service is updated and the proxy on the client is not then the application might behave incorrectly.

There is no need to have a proxy at the client end because its only data that is coming and the application can directly receive and process the data.

Usage of SOAP and REST

SOAP(when to use SOAP)

REST(when to use REST)

When designing an application of a service oriented architecture that interconnects many systems and uses many transport channels, it is better to use SOAP.

When we plan to design an application to be used exclusively on the web and also when we need quick client integration.

Complex Applications that need a different kind of bindings and protocols.

Simple applications that highly depend on CRUD operations.

Disadvantages of REST

  • No Metadata
  • Only HTTP Security
  • Complexity kills

References


Similar Articles