Benefits of using RESTful WCF Services

Facebooktwittergoogle_pluslinkedinmail

Overview

WCF Restful service is a simple yet very useful concept of WCF Services. Either in .Net 2.0 or .Net 3.5 the web services whether by ASMX or WCF have been implemented using SOAP and WS-* standards. WS-* Standards are extensions of the SOAP specification which defines the Advance level functionalities such as Transactions, Reliable Messaging and much more. There is no doubt that if you create the web service using SOAP protocol with HTTP carrier, you can create viable solution for big Enterprise Problems. Due that SOAP is a very heavy weight and complex protocol; it cannot be easily readable by human. It also contains lot of extra xml markups which are protocol oriented or sometimes really not required by the solution. Those xml markups increase the size of the messages resulting into higher data transfer rate on the wire.

In the release of .Net 3.5 Framework WCF offers support for both the programming model Web & SOAP. So the Restful web services are nothing but a web programming model to expose WCF Service. REST can have more impact on data transfer reduction in combination with JSON or other serialization techniques.
What is REST?

REST stands for REpresentation State Transfer. Representation State Transfer term is invented by one of the original author of the HTTP protocol, Roy Fielding in his 2000 doctoral dissertation. Visit the wiki for more about REST.
Key concepts of REST

  • Resources: Resources are nothing but entities in a business domain for ex. Items, Vendors, Customer etc…
  • URIs: All resources are referenced using URIs (Universal Resource Identifiers)
  • Representations: It consist of 2 things Data that reflects current or desired state, meta data that provides description of data values. For ex. HTML, XML, JSON, Text files, zip, Images, Mpegs etc…

Limited Set of Methods

There are uniform interfaces like methods, operations, verbs

Verbs are actually HTTP verbs

GET

  • Retrieves a resource
  • Guaranteed not to cause side-effect (SAFE)
  • Cacheable

POST

  • Creates a new resource
  • Unsafe, effect of this verb isn’t defined by HTTP

PUT

  • Updates an existing resource
  • Used for resource creation when client knows URI
  • Can call N times, same thing will always happen

DELETE

  • Remove a resource
  • Can call N times, same thing will always happen

IMPLICIT INTERFACE DESIGN

  • REST does not call meta-languages to describe Structure of representations, Data Types used in representations, What operations are supported at a given URI, How input data must be sent for a given URI/Operation combination.

Why to Prefer REST?

  • REST is powerful, intuitive, and relatively easy to implement.
  • Light weight – not lot of extra xml markup as in SOAP.
  • Unlike SOAP it provides much simpler result that can be human readable.
  • It is very easy to build no extra toolkits are required.
  • Improve scalability of the application through caching and session state.
  • Custom URIs using URI templates
  • Consistency with design of the World Wide Web

Examples

Below examples are taken from one of our existing project & describes how the message size on the wire has been reduced to optimize the performance and reduce the cost overhead when the Bandwidth is concerned as per business need.

SOAP vs. REST

Above example clearly indicates that WCF REST services better takes care of Data usage size than the WCF SOAP services. Hence, whenever data usage size is a matter of concern, WCF REST is the way to go.

Gateway Technolabs

Gateway Technolabs

Marketing & Communication Department at Gateway TechnoLabs Pvt. Ltd.
EXPERTS AT KEEPING
EXPENSIVE BUSINESS DECISIONS 'PROFITABLE'.
SINCE 1997.
Gateway Technolabs

Published by

Gateway Technolabs

EXPERTS AT KEEPING EXPENSIVE BUSINESS DECISIONS 'PROFITABLE'. SINCE 1997.

Leave a Reply

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