WebService - a way of servicing someone (like "giveMeSomething" sort of way) over the web
REST - Representational state transfer. We're transferring a representation of the state (of someone) - not servicing anybody.
To see why is this so damn important first let's see what classic SOAP web services look like in practice. They consist of 3 things:
1. WSDL / XSD (description)
2. Endpoint (URL)
3. XML (data)
In fact there's one most important thing to note: the "endpoint" is/has usually a verb: "go get some flowers", "fetch history", "make me pretty" - you get the idea, right?
Now on the other hand REST has nothing to do with verbs - REST deals with nouns: people, cars, addresses, gasoline, money... So how do you make a person give money for gasoline for their car to allow them to get to a certain address they are heading?
WebService: MySuperDuperWebService.makeHimPay(Double money) REST : GET /person/54623445/account/1/balance (get the current balance) PUT /person/54623445/account/1/balance + current balance
The difference here is you're not giving a REST place orders other than update, delete, retrieve.
So the next time you'll be tempted to say REST service please bear in mind there's no such thing. What is however named as a "REST service" is a URL, that responds (usually) to POST (cuz that's so damn easier to pass data to) that has no predefined schema (usually..) and that instead of giving you back XML hands you over JSON (possibly using JSONP). That my friends is a definition of a JSON Service and has nothing, absolutely nothing to do with REST whatsoever. Even worse is the term RESTful web service. My God is that a horrible thing to say. It seems like the service being referred to rusts in peace and should never ever be called.
Make the world better for a change!
No comments:
Post a Comment