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:
It can be through knowledge / experience or reference sources.
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:
It can be through knowledge / experience or reference sources.
Confusing POX web services as "REST", many web API implementations never fully exploit the RESTful architecture.
REST vs RPC
REST is not a framework such as WCF, a protocol such as HTTP, a framework like JAX-RS, or a communication format such as SOAP. REST is an architecture, a structured way to represent a software solution - specifically, exposing aspects of a solution to a set of remote client-clients. The central tenet of REST is that these aspects of a solution can be modeled as resources that the client can consume or interact with.
This resource-oriented thinking, not the implementation details of how client-server communication is, is what REST really is. This is the fundamental difference that separates actual RESTful RPC APIs based on HTTP verbs.
Why is this important? The RESTful approach allows us to model our domain objects as hierarchical URLs consistent with predictive (loosely) semantic mapping for CRUD. Because HTTP comes with standard error codes, MIME types, and usually does most of the heavy work, it is interesting to benefit from the need to maintain a stack of user-developed protocols, which is subject to frequent modification. / p>
The fundamental problem with RPC is coupling. RPC clients become closely linked to the implementation service in many ways and it becomes very difficult to change service implementation without breaking clients.
Consider the following example of HTTP APIs that model the orders of a restaurant.
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 an order:
RPC : http://MyRestaurant:8080/Orders/GetOrder?OrderNumber=asdf (GET)
REST : http://MyRestaurant:8080/Orders/Order?OrderNumber=asdf (GET)
Updating an order:
RPC : 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: