REST是更好的Web服务方法还是SOAP?或者它们是针对不同问题的不同工具?或者这是一个微妙的问题——也就是说,一个人在某些领域比另一个人稍微好一点,等等?
我尤其希望了解这些概念以及它们与php世界以及现代高端网络应用程序的关系。
REST是更好的Web服务方法还是SOAP?或者它们是针对不同问题的不同工具?或者这是一个微妙的问题——也就是说,一个人在某些领域比另一个人稍微好一点,等等?
我尤其希望了解这些概念以及它们与php世界以及现代高端网络应用程序的关系。
当前回答
我认为两者都有自己的位置。在我看来:
SOAP:传统/关键系统和web/web服务系统之间集成的更好选择,在基础层,其中WS-*是有意义的(安全,策略等)。
RESTful:一个更好的网站集成的选择,公共API,在层的顶部(VIEW,即javascript调用uri)。
其他回答
SOAP体现了Web服务的面向服务的方法——在这种方法中,方法(或动词)是与服务交互的主要方式。REST采用面向资源的方法,其中对象(或名词)占据中心位置。
快速了解一下2012年的问题:
REST在以下方面发挥了很好的作用:
Limited bandwidth and resources. Remember the return structure is really in any format (developer defined). Plus, any browser can be used because the REST approach uses the standard GET, PUT, POST, and DELETE verbs. Again, remember that REST can also use the XMLHttpRequest object that most modern browsers support today, which adds an extra bonus of AJAX. Totally stateless operations. If an operation needs to be continued, then REST is not the best approach and SOAP may fit it better. However, if you need stateless CRUD (Create, Read, Update, and Delete) operations, then REST is it. Caching situations. If the information can be cached because of the totally stateless operation of the REST approach, this is perfect.That covers a lot of solutions in the above three.
那么我为什么要考虑SOAP呢?同样,SOAP是相当成熟和定义良好的,并且带有完整的规范。REST方法就是这样一种方法,它对开发非常开放,所以如果你具备以下条件,那么SOAP就是一个很好的解决方案:
Asynchronous processing and invocation. If your application needs a guaranteed level of reliability and security then SOAP 1.2 offers additional standards to ensure this type of operation. Things like WSRM – WS-Reliable Messaging. Formal contracts. If both sides (provider and consumer) have to agree on the exchange format then SOAP 1.2 gives the rigid specifications for this type of interaction. Stateful operations. If the application needs contextual information and conversational state management then SOAP 1.2 has the additional specification in the WS* structure to support those things (Security, Transactions, Coordination, etc). Comparatively, the REST approach would make the developers build this custom plumbing.
http://www.infoq.com/articles/rest-soap-when-to-use-each
我相信Don Box创建SOAP是一个笑话——“看,你可以在web上调用RPC方法”,今天当他意识到它已经成为一个臃肿的web标准的噩梦时,他会呻吟:-)
REST很好,很简单,在任何地方都可以实现(所以它更像是一个“标准”,而不是标准),又快又简单。使用REST。
请收听本期播客找出答案。如果你想在不听的情况下知道答案,那么好吧,这是REST。但我真的建议你听。
1.从我的经验来看。我想说REST让你可以选择访问已经构建好的URL。>一个词搜索谷歌。该URL可以用作REST的web服务。 在SOAP中,您可以创建自己的web服务并通过SOAP客户机访问它。
REST支持文本、JSON、XML格式。因此,两个应用程序之间的通信更加通用。而SOAP仅支持XML格式的消息通信。