views:

69

answers:

3

Hello.

I'm starting in the web-services world and I have a few questions:

  • From what I've read, REST could be understood as a simple call to a URL which gives a certain expected result. So, what is the difference between a REST web-service and a simple website?

  • Web-services are language-independent. So, if I'm developing a Java-based REST web-service with a method that returns a serialized "Person" class object, and my client is a .NET application, how can this class be reconstructed on the .NET side? How is it done in practice? Do I have to build a representation of the returned object on the web-service and on the .NET side parse it and build it?

  • In practice, whats is the difference between REST and SOAP calls?

Thanks in advance.

+1  A: 

REST stands for Representative State Transfer. It is built on the fact that the HTTP protocol is stateless, and specifies some methods like PUT/GET/POST etc. REST attaches semantics to those methods. For example, a GET means 'Read/Load'. PUT means 'save'. POST means 'update'. (I think I got that right...)

So REST is not a call to a URL, REST is a concept. You use REST by making calls to Urls. The difference between REST and a 'simple website' is the REST semantics. A PUT request means one thing, a GET request means another, etc.

RESTful webservices are language independent because the depend on the HTTP protocol; thats it. They don't depend on any language features, other than the ability to use the HTTP protocol.

hvgotcodes
Actually, HTTP RFC2616 attaches semantics to the methods. REST just requires that if you use HTTP, to use HTTP consistently to conform to the Uniform Interface constraint. REST is actually not dependent on HTTP either, but in practice that is what is used 99% of the time.
Darrel Miller
@darrel, nice commentary.
hvgotcodes
+4  A: 

See the Richardson Maturity Model for an explanation on what a RESTful service is.

alt text

To reach level 3 one must satisfy the Hypermedia as the Engine of Application State. abrivated HATEOAS constraint (also called the Hypermedia constraint). This means that most services out there is not RESTful, but merly CRUD services... which is fine...

A good resource on REST is REST in Practice

The main difference between SOAP and REST is that REST services does not have a WSDL defining the "operations", thank god for that. Yet the data structures can be defined by a schema language such as Schematron, XSD for XML...

TTMAN
The explanation of hypermedia controls was pretty good. Thx for the link.
Noel Abrahams
A: 
  • REST returns structured XML or JSON data, you don't send back an entire webpage, which could be hard to interpret, and would be unnecessarily complicated.

  • You can parse XML or JSON data into an object in any language with a parser for this (including the .net languages). An object in this sense doesn't mean a full fledged .net object with a vtable etc.

  • SOAP overloads the POST data sent with an HTTP request, and hence instead of having many URLs to which you send individual requests, you just have one URL to which you post some XML data. In reality, the difference is mostly semantic.

Aurojit Panda
REST does not constrain the media type you return. Returning HTML is actually far more compliant with REST constraints than returning application/xml and application/json and assuming semantic value within those generic representations.
Darrel Miller