为什么大多数Web服务都是REST风格,而不是(也)在XML-RPC中?

时间:2022-01-30 19:33:16

I know that Flickr provides both XML-RPC and REST ways of working with it.

我知道Flickr提供了XML-RPC和REST的使用方法。

There are standard XML-RPC libraries for every language (For example, Python has a built-in one xmlrpclib).

每种语言都有标准的XML-RPC库(例如,Python有一个内置的xmlrpclib)。

Standard XML-RPC libraries takes care of the serializing/deserializing as well as sending/receiving the responses.

标准XML-RPC库负责序列化/反序列化以及发送/接收响应。

It seems to me that websites that use the REST style for the same API would end up writing their own libraries in each language. Example: the Yahoo! Search SDK.

在我看来,对同一API使用REST样式的网站最终会在每种语言中编写自己的库。示例:Yahoo!搜索SDK。

To me, it seems that the XML-RPC way is better, but all the evidence is to the contrary. Why?

对我来说,似乎XML-RPC方式更好,但所有证据都是相反的。为什么?

So:

  1. Why are most web services in REST style, and not in XML-RPC?
  2. 为什么大多数Web服务都是REST风格,而不是XML-RPC?

  3. Are there downsides to XML-RPC that is not apparent?
  4. XML-RPC的缺点是不明显的?

5 个解决方案

#1


  1. Rest is not just easier, its a lot easier.

    休息不仅容易,而且更容易。

  2. Xml-Rpc/soap has a lot of moving parts and a hefty amount of overhead, cognitive
    and otherwise which (very often) is not needed, its complex and unless you specifically need some of the features it provides it's just not worth it

    Xml-Rpc / soap有很多活动部件和大量的开销,认知和其他(通常)不需要,它的复杂性,除非你特别需要它提供的一些功能,否则它是不值得的

  3. Not every service request needs to be packaged up as a formal function call with parameters

    并非每个服务请求都需要打包为带参数的正式函数调用

  4. REST is also a formal system that's well defined and a great model for representing the resources available on the web (hence the term REST)

    REST也是一个定义良好的正式系统,是表示Web上可用资源的一个很好的模型(因此称为REST)

Having said that, it's easy to make a lot of newbie mistakes using REST so google around for how to use it first, you'll be happy you did.

话虽如此,使用REST很容易犯很多新手错误,所以谷歌首先要知道如何使用它,你会很开心。

#2


This is a great question. Unless you are taking advantage of hypermedia for discovery and standard media formats then you are not likely to be getting the benefits of REST. You might as well stick with XML-RPC.

这是一个很好的问题。除非您利用超媒体进行发现和标准媒体格式,否则您不太可能从REST中获益。您也可以坚持使用XML-RPC。

#3


Simple Answer: REST tends to be easier to implement

简单回答:REST往往更容易实现

#4


there are many discussions on that on the web, so I won't go deep on the answer. In short: It's easy. Easy to write, easy to understand, easy to debug. You can write it on your browser and it will probably bring back something useful. Very good.

网上有很多关于此的讨论,所以我不会深入研究答案。简而言之:这很容易。易于编写,易于理解,易于调试。您可以在浏览器上编写它,它可能会带来一些有用的东西。很好。

This easiness come at the price of less "possibilities" but the theory goes that in the long run, easiness might be more worthy.

这种容易性是以较少的“可能性”为代价的,但理论认为,从长远来看,宽松可能更有价值。

#5


REST is the native architectural style of the Web. (In fact, it was reverse-engineered from the way the Web already works.) XML-RPC and SOAP attempt to take a very different (procedural, imperative) programming model and adapt it to the web. The result is that REST ends up being cleaner and more flexible.

REST是Web的本机架构风格。 (事实上​​,它是从Web已经运行的方式进行反向设计的。)XML-RPC和SOAP尝试采用一种非常不同的(程序性的,命令性的)编程模型并使其适应Web。结果是REST最终变得更干净,更灵活。

#1


  1. Rest is not just easier, its a lot easier.

    休息不仅容易,而且更容易。

  2. Xml-Rpc/soap has a lot of moving parts and a hefty amount of overhead, cognitive
    and otherwise which (very often) is not needed, its complex and unless you specifically need some of the features it provides it's just not worth it

    Xml-Rpc / soap有很多活动部件和大量的开销,认知和其他(通常)不需要,它的复杂性,除非你特别需要它提供的一些功能,否则它是不值得的

  3. Not every service request needs to be packaged up as a formal function call with parameters

    并非每个服务请求都需要打包为带参数的正式函数调用

  4. REST is also a formal system that's well defined and a great model for representing the resources available on the web (hence the term REST)

    REST也是一个定义良好的正式系统,是表示Web上可用资源的一个很好的模型(因此称为REST)

Having said that, it's easy to make a lot of newbie mistakes using REST so google around for how to use it first, you'll be happy you did.

话虽如此,使用REST很容易犯很多新手错误,所以谷歌首先要知道如何使用它,你会很开心。

#2


This is a great question. Unless you are taking advantage of hypermedia for discovery and standard media formats then you are not likely to be getting the benefits of REST. You might as well stick with XML-RPC.

这是一个很好的问题。除非您利用超媒体进行发现和标准媒体格式,否则您不太可能从REST中获益。您也可以坚持使用XML-RPC。

#3


Simple Answer: REST tends to be easier to implement

简单回答:REST往往更容易实现

#4


there are many discussions on that on the web, so I won't go deep on the answer. In short: It's easy. Easy to write, easy to understand, easy to debug. You can write it on your browser and it will probably bring back something useful. Very good.

网上有很多关于此的讨论,所以我不会深入研究答案。简而言之:这很容易。易于编写,易于理解,易于调试。您可以在浏览器上编写它,它可能会带来一些有用的东西。很好。

This easiness come at the price of less "possibilities" but the theory goes that in the long run, easiness might be more worthy.

这种容易性是以较少的“可能性”为代价的,但理论认为,从长远来看,宽松可能更有价值。

#5


REST is the native architectural style of the Web. (In fact, it was reverse-engineered from the way the Web already works.) XML-RPC and SOAP attempt to take a very different (procedural, imperative) programming model and adapt it to the web. The result is that REST ends up being cleaner and more flexible.

REST是Web的本机架构风格。 (事实上​​,它是从Web已经运行的方式进行反向设计的。)XML-RPC和SOAP尝试采用一种非常不同的(程序性的,命令性的)编程模型并使其适应Web。结果是REST最终变得更干净,更灵活。