Restful Web服务如何比基于SOAP的Web服务更好 [英] how is Restful web services better than SOAP based webservices

查看:107
本文介绍了Restful Web服务如何比基于SOAP的Web服务更好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览过各种网站,他们提供的唯一答案是 - Restful webservices使用Http自己的方法,如(GET,POST,PUT,DELETE)。而基于SOAP的webservices使用自己的自定义方法。 。
- Restful Web服务将每个服务方法视为资源并为其提供URI ..

I Have gone through various sites and the only answer they provide is - Restful webservices makes use of Http's own methods such as (GET,POST,PUT,DELETE).. Whereas SOAP based webservices makes use of its own custom methods.. - Restful web services treats each service method as a resource and gives it a URI..

但是我不明白这些答案的全部意义。至于为什么这些东西比基于SOAP的Web服务证明是一个很大的优势..

However I do not understand the full significance of these answers.. As to why these things prove to be such a big advantage over SOAP based web services..

一个例子将被赞赏

推荐答案

REST自然适用于Web / Cloud API,而SOAP适用于分布式计算场景。

REST naturally fits for Web/Cloud API's, whilst SOAP fits for distributed computing scenarios.

带宽是REST的主要好处,因为没有复杂的文档可以遍历(即XML,SOAP标头),这对于性能良好的Web API非常重要。 JSON是一种广泛认可且简单的数据交换标准,易于被浏览器和客户端代码读取,这就是为什么大多数RESTful API(雅虎都是一个很好的例子)提供JSON。

Bandwidth is the main benefit of REST, as there is no complex document to traverse (ie XML, SOAP headers), which is extremely important for well performing Web API's. JSON is a widely-recognized and simple standard for data exchange, and is easily read by browsers and client code, which is why most RESTful API's (Yahoo is a good example) offer JSON.

更不用说REST可用于XmlHttpRequest对象,这对于Web API的AJAX能力也是至关重要的。

Not to mention REST is available to the XmlHttpRequest object, which again, is crucial for AJAX-ability for Web API's.

当然还有可缓存性功能REST不容忽视。因为REST基于HTTP,所以它可以利用HTTP(和Web本身)的许多语义,通过利用HTTP数据包(过期)上的标头来启用浏览器的缓存。更不用说像gzip压缩这样的东西来提高效率。性能方面,REST确实将它钉在了SOAP上。

And of course the cacheability feature of REST cannot be ignored. Because REST is based on HTTP, it can take advantage of many of the semantics of HTTP (and the web itself), by utilizing headers on the HTTP packets (expires) to enable caching by the browser. Not to mention things like gzip compression to increase efficiency. Performance-wise, REST really nails it over SOAP.

对于SOAP,SOAP很好地满足了有状态操作。 WS *标准(安全性,事务等)处理这种管道,这在分布式场景中非常常见。当然,它可以通过REST来完成,但它确实不是REST。 SOAP非常适合在客户端和服务器之间定义操作契约,这在分布式场景中是至关重要的。

As for SOAP, well SOAP caters for stateful operations. The WS* standard (Security, Transactions, etc) handle this sort of plumbing which is quite common in distributed scenarios. It can be done with REST, sure, but then it wouldn't really be REST. SOAP is really good for defining operational contracts between client and server, which is crucial in distributed scenarios.

所以我的观点(以及整个SOAP vs REST的事情是高度自以为是的) ,将SOAP用于分布式计算场景,将REST用于Web API。

So my opinion (and the whole SOAP vs REST thing is highly opinionated), use SOAP for distributed computing scenarios, use REST for Web API's.

这篇关于Restful Web服务如何比基于SOAP的Web服务更好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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