REST and WCF 3.5

The first version of WCF was focused on SOAP. But another approach known as REST is becoming a popular approach for building web services. The latest version of WCF in the .NET Framework 3.5 supports both SOAP and REST.

What is REST?

REST is an acronym standing for Representational State Transfer and it is an architecture style of networked systems. According to Roy Fielding (one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification) , the explanation of Representational State Transfer is :
"Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use." Systems that follow Fielding’s REST principles are commonly known as “RESTful”;

REST means that each unique URL is a representation of some object. You can get the contents of that object using an HTTP GET, to delete it, you then might use a POST, PUT, or DELETE to modify the object.

Unlike SOAP, REST is not a standard or specification. It is just an architectural style. You can design your web services using this architectural style.

REST is using the built-in operations in HTTP: GET, POST, and others. And rather than identify the information to be accessed with parameters defined in XML, as SOAP typically does, REST assumes that everything is identified with a URL. However REST is not a standard, it does use the following standards


  • HTTP
  • URL
  • XML/HTML/GIF/JPEG/etc (Resource Representations)
  • text/xml, text/html, image/gif, image/jpeg, etc

REST Vs SOAP - Which is the best approach?

Software Architects have been involving a never-ending debate about whether SOAP-based or REST-style web services are the right approach and recently the debate is too heating up. Yahoo's web services are using REST and google using SOAP for their web services. Some organizations have web services for both REST and SOAP. REST is Lightweight than SOAP because it does not requires lot of xml markup like SOAP.
I believe that SOAP will be the primary choice for intranet and enterprise level applications because SOAP and the WS-* specifications addresses many challenges of enterprise level applications such as reliability, distributed transactions, and other WS-* services. But I think open, Internet applications will gear towards to REST because of REST’s explicitly Web-based approach and its simplicity.

RESTful services for WCF 3.5

WCF 3.5 provides explicit support for RESTful communication using a new binding named WebHttpBinding.
The below code shows how to expose a RESTful service

[ServiceContract]
interface IStock
{
[OperationContract]
[WebGet]
int GetStock(string StockId);
}


By adding the WebGetAttribute, we can define a service as REST based service that can be accessible using HTTP GET operation.

Published Friday, April 04, 2008 12:13 AM by shiju
Filed under: ,

Comments

# re: REST and WCF 3.5

Friday, April 04, 2008 2:30 AM by kamii47

{

I believe that SOAP will be the primary choice for intranet and enterprise level applications because SOAP and the WS-* specifications addresses many challenges of enterprise level applications such as reliability, distributed transactions, and other

}

Does this mean REST doesn't addressess these things?

# Web Design » REST and WCF 3.5

Friday, April 04, 2008 9:15 AM by Web Design » REST and WCF 3.5

Pingback from  Web Design » REST and WCF 3.5

# re: REST and WCF 3.5

Friday, April 04, 2008 10:18 AM by Guy

Nice post, and a very concise and clear explanation.

Thanks!

# re: REST and WCF 3.5

Saturday, April 12, 2008 3:14 AM by shiju

Hi kamii47,

REST does not support distributed trasactions. However the need for transactions is actually a design philosophy. You can use and adopt REST using best practices.

Have a look at www.infoq.com/.../tilkov-rest-doubts.

Regards,

Shiju

# architectural software

Wednesday, April 16, 2008 4:21 PM by architectural software

Pingback from  architectural software

# istock

Thursday, April 17, 2008 2:52 AM by istock

Pingback from  istock

# hypertext transfer protocol

Friday, April 18, 2008 11:19 AM by hypertext transfer protocol

Pingback from  hypertext transfer protocol

# re: REST and WCF 3.5

Sunday, May 04, 2008 5:54 AM by Robert Hormozi

Fantastic article in identifying what REST is. Thank you, keep at it.

# re: REST and WCF 3.5

Tuesday, May 13, 2008 8:10 AM by merC

Nice article mate.. it gives a brief and very clear idea about REST.

# Rinsing the SOAP from WCF (or, RESTful WCF Hyperlink Acupuncture) | The Freak Parade

Pingback from  Rinsing the SOAP from WCF (or, RESTful WCF Hyperlink Acupuncture) | The Freak Parade

# re: REST and WCF 3.5

Wednesday, August 20, 2008 9:57 PM by Christopher

Thanks for the article. You mentioned that Google uses SOAP. The only use of SOAP by Google that I could find is their SOAP search API, which was deprecated in 2006. Is there some other SOAP API that Google provides?

# re: REST and WCF 3.5

Monday, January 05, 2009 1:51 AM by Umamahesh

Nice post mate..clear explanation....

# re: REST and WCF 3.5

Thursday, March 26, 2009 6:36 AM by Agenext

This is really nice article. Keep writing :)

# re: REST and WCF 3.5

Wednesday, July 01, 2009 9:01 AM by praveen satti

this is really nice and compact but what if i want to know about it in details like having a practical sample resource for RESTFul development

# re: REST and WCF 3.5

Tuesday, August 04, 2009 1:53 PM by Jess

Good post shiju, Keep it...

Leave a Comment

(required) 
(required) 
(optional)
(required)