XML-RPC与REST [英] XML-RPC vs REST

查看:70
本文介绍了XML-RPC与REST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个更具理论性的问题.我将在此处构建一个小型服务器,并希望为其创建一个API.我正在决定什么更好,并且已经排除了SOAP,因为我认为那是一团糟.我只剩下REST和XML-RPC.我真的很喜欢XML-RPC,它真的很容易实现,而且它很普通,以至于所有客户端都可以轻松使用它.这些天来,所有很酷的孩子都在做RESTful的工作,有时使用JSON负载或XML文档,甚至使用HTTP POST VARIABLES.我认为这些家伙总是为每种服务重新发明轮子.我看不到通过使用REST而不是使用XML-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.

那么,有人可以提供使用REST + JSON而不是仅使用XML-RPC来实现API的实际原因吗?

So, can someone here provide practical reasons for implementing an API using REST+JSON over just using XML-RPC?

推荐答案

REST与RPC实现(例如XML-RPC)是二分法.您可以使用XML-RPC实现RESTful接口(尽管您可能不想这样做).就是说,有很多原因使您想要使用原始HTTP以RESTful方式公开资源,而不是使用XML-RPC之类的技术来滚动自己的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:

  1. 未来动作主要由服务器控制,而不是通过过程调用在客户端进行硬编码,从而简化了部署和版本控制.
  2. 可以立即使用诸如缓存,限制和版本控制之类的现有实现.
  3. 使用RPC接口滚动的自定义过程的范围可能过于狭窄.

有关更多信息,请参见博客文章.

See this blog post for more info.

这篇关于XML-RPC与REST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆