1.
What is Rest
REST service is based on HTTP protocol. Each
method invocation is a http get,post,delete or put request. Since it is HTTP
protocol based so anything that can talk http can consume your service without
much effort i.e. javascript, C#, Java, Whatever.
Also REST call results can be cached like
normal http pages (by intermediate proxies or client machine) if you send the
right caching parameters with the response.
However it is also more oriented towards
'resources' while normal WCF service is oriented towards RPC style
communication.
Normal WCF supports callbacks and whole lot
of other things that REST doesn't support but obviously it comes with cost of
platform compatibility and complexity.
2.
What is
Advantages of consuming RESTful services
- · 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
- · Lightweight - not a lot of extra xml markup
- · Human Readable Results
- · Easy to build - no toolkits required
- · Each operation in a service is uniquely identified.
- · Each operation has their, own unique URI and can be accessed via this URL all across the web.
- · Each URL is an object representation.
- · The Object can retreived using HTTP GET.
- · The Object can be deleted using a POST or PUT, use DELETE to modify the object
- · It is firewall friendly and it is fairly simple and straight forward.
3.
More About
RESTful services
- 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.
- 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.
4.
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…
5.
Example
[OperationContract(Name = " AddTwoNumber ")]
[WebInvoke(UriTemplate = "/", Method = "POST")]
int AddTwoNumber(int i, int j);
[OperationContract(Name = " SubTwoNumber")]
[WebGet(UriTemplate = "/")]
int SubTwoNumber(int i, int j);
Happy
Programming!!
Don’t forget to leave your feedback and comments below!
If
you have any query mail me to Sujeet.bhujbal@gmail.com
Regards
Sujeet
Bhujbal
--------------------------------------------------------------------------------
Personal Website :-http://sujitbhujbal.wordpress.com/
Facebook :-www.facebook.com/sujit.bhujbal
CodeProject:-http://www.codeproject.com/Members/Sujit-Bhujbal
Linkedin :-http://in.linkedin.com/in/sujitbhujbal
Stack-Exchange: http://stackexchange.com/users/469811/sujit-bhujbal
Twitter :-http://twitter.com/SujeetBhujbal
JavaTalks :-http://www.javatalks.com/Blogger/sujit9923/
-----------------------------------------------------------------------------------
No comments:
Post a Comment