XML-RPC 与 REST [英] XML-RPC vs REST
问题描述
这是一个更理论化的问题.我即将在这里构建一个小服务器,并想为它创建一个 API.我正在决定什么更好,并且已经排除了 SOAP,因为在我看来那是一团糟.我只剩下 REST 和 XML-RPC.我真的很喜欢 XML-RPC,它实现起来真的很简单,而且它足够规则,所有客户端都可以轻松使用它.如今,所有酷孩子都在做 RESTful 的事情,有时使用 JSON 有效负载或 XML 文档,甚至 HTTP POST 变量.我认为这些人总是为每项服务重新发明轮子.我看不出通过使用 REST 而不是使用 XML-RPC 可以获得什么.
那么,这里有人可以提供使用 REST+JSON 而非仅使用 XML-RPC 实现 API 的实际理由吗?
像 XML-RPC 这样的 REST 与 RPC 实现是错误的二分法.您可以使用 XML-RPC 实现 RESTful 接口(尽管您可能不想这样做).也就是说,您希望使用普通 HTTP 以 RESTful 方式公开资源而不是使用 XML-RPC 之类的技术滚动您自己的 RPC 接口的原因有很多:
- 未来的操作主要由服务器控制,而不是通过过程调用在客户端进行硬编码,从而简化部署和版本控制.
- 可以开箱即用地使用缓存、限制和版本控制等现有实现.
- 您使用 RPC 接口滚动的自定义过程可能范围太窄.
有关详细信息,请参阅这篇博文.>
This is a more theoretical question. I am about to build a little server in here and want to create an API for it. I am deciding what is better and already ruled out SOAP since that thing is a mess in my opinion. I am left with REST and XML-RPC. I really enjoy XML-RPC, it is really simple to implement and it is regular enough that all clients can use it easily. These days all the cool kids are doing RESTful stuff, sometimes with a JSON payload or XML document or even HTTP POST VARIABLES. I think those guys always reinvent the wheel for each service. I don't see what one could gain by going with REST over using XML-RPC.
So, can someone here provide practical reasons for implementing an API using REST+JSON over just using XML-RPC?
REST vs RPC implementations like XML-RPC is a false dichotomy. You can implement a RESTful interface using XML-RPC (although you probably wouldn't want to). That said, there are a bunch of reasons why you would want to expose resources in a RESTful way using vanilla HTTP instead of rolling your own RPC interface using a technology like XML-RPC:
- Future actions are primarily controlled by the server instead of hard-coded in the client via procedure calls, simplifying deployment and versioning.
- Existing implementations for things like caching, throttling, and versioning can be used out of the box.
- The custom procedures that you roll with an RPC interface are likely to be too narrowly scoped.
See this blog post for more info.
这篇关于XML-RPC 与 REST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!