2
Between developing an API using JSON-RPC or REST (RESTFULL), I would like to know in which cases there are advantages/disadvantages in using one or the other.
OBS:
This may be through knowledge/experience or reference sources.
2
Between developing an API using JSON-RPC or REST (RESTFULL), I would like to know in which cases there are advantages/disadvantages in using one or the other.
OBS:
This may be through knowledge/experience or reference sources.
2
One of the most common misconceptions is that any call that uses HTTP verbs such as GET, PUT, POST rather than using SOAP links to expose an end-point service is called "Restful". This blurring of the line between REST and XML-RPC (or JSON-RPC, etc.) has some very significant practical consequences.
Confusing POX web services as "REST", many web API implementations never fully exploit the Restful architecture.
REST vs RPC
REST is not a framework like WCF, a protocol like HTTP, a framework like JAX-RS, or a communication format like SOAP. REST is an architecture, a structured way of representing a software solution - specifically, by exposing the aspects of a solution to a set of remote customers-consumers. The core principle of REST is that these aspects of a solution can be modeled as resources that the customer can consume or interact with.
This resource-oriented thinking, and not the implementation details of how communication between client and server takes place, is what REST really is. This is the fundamental difference between real Restful Apis and RPC based on HTTP verbs.
Why is this important? The Restful approach allows us to model our domain objects as hierarchical Urls consistent with semantic and predictable (vaguely) mapping to CRUD. Since HTTP comes with standard error codes, MIME types and generally does most of the heavy lifting, it is interesting to benefit from the no need to maintain a stack of protocols developed by the user, and which is subject to frequent modification.
The fundamental problem with PRC is coupling. RPC customers become closely linked to the implementation service in various ways and it becomes very difficult to change service implementation without breaking customers.
Consider the following example of HTTP Apis that model restaurant orders.
Examples:
Add an order:
http://MyRestaurant:8080/Orders/PlaceOrder (POST: <Order OrderNumber="asdf"><Appetizer><Appetizer><Entree>Tacos</Entree><! --Rest of the order--></Order>)
http://MyRestaurant:8080/Orders/Order?OrderNumber=asdf (POST:
<Order><Appetizer><Appetizer><Entree>Tacos</Entree><! --Rest of the
order--></Order>)
Retrieving a request:
PRC: http://MyRestaurant:8080/Orders/GetOrder?OrderNumber=asdf (GET)
REST: http://MyRestaurant:8080/Orders/Order?OrderNumber=asdf (GET)
Updating an order:
PRC: http://MyRestaurant:8080/Orders/UpdateOrder (PUT: <Order OrderNumber="asdf"><Appetizer><Appetizer><Entree>Pineapple
Tacos</Entree><! --Rest of the order--></Order>)
REST: http://MyRestaurant:8080/Orders/Order?OrderNumber=asdf (PUT: <Order><Appetizer><Appetizer><Entree>Pineapple Tacos</Entree><!
--Rest of the order--></Order>)
References:
Browser other questions tagged json web-service api rest restful
You are not signed in. Login or sign up in order to post.