Web service differences between REST and RPC
I have a web service that accepts JSON parameters and have specific URLs for methods, eg:
http://IP:PORT/API/getAllData?p={JSON}
This is definitely not REST as it is not stateless. It takes cookies into account and has its own session.
Is it RPC? What is the difference between RPC and REST?
You can't make a clear separation between REST or RPC just by looking at what you posted.
One constraint of REST is that it has to be stateless. If you have a session then you have state so you can't call your service RESTful.
The fact that you have an action in your URL (ie getAllData
) is an indication towards RPC. In REST you exchange representations and the operation you perform is dictated by the HTTP verbs. Also, in REST, Content negotiation isn't performed with a ?p={JSON}
parameter.
Don't know if your service is RPC, but it is not RESTful. You can learn about the difference online, here's an article to get you started: Debunking the Myths of RPC & REST. You know better what's inside your service so compare it's functions to what RPC is and draw your own conclusions.
Consider the following example of HTTP APIs that model orders being placed in a restaurant.
Placing an Order:
Retrieving an Order:
Updating an Order:
Example taken from sites.google.com/site/wagingguerillasoftware/rest-series/what-is-restful-rest-vs-rpc
REST is best described to work with the resources, where as RPC is more about the actions.
REST stands for Representational State Transfer. It is a simple way to organize interactions between independent systems. RESTful applications commonly use HTTP requests to post data (create and/or update), read data (eg, make queries), and delete data. Thus, REST can use HTTP for all four CRUD (Create/Read/Update/Delete) operations.
RPC is basically used to communicate across the different modules to serve user requests. eg In openstack like how nova, glance and neutron work together when booting a virtual machine.
链接地址: http://www.djcxy.com/p/71470.html上一篇: SOAP为什么/如何是有状态的?
下一篇: REST和RPC之间的Web服务差异