REST是更好的Web服务方法还是SOAP?或者它们是针对不同问题的不同工具?或者这是一个微妙的问题——也就是说,一个人在某些领域比另一个人稍微好一点,等等?
我尤其希望了解这些概念以及它们与php世界以及现代高端网络应用程序的关系。
REST是更好的Web服务方法还是SOAP?或者它们是针对不同问题的不同工具?或者这是一个微妙的问题——也就是说,一个人在某些领域比另一个人稍微好一点,等等?
我尤其希望了解这些概念以及它们与php世界以及现代高端网络应用程序的关系。
当前回答
我认为两者都有自己的位置。在我看来:
SOAP:传统/关键系统和web/web服务系统之间集成的更好选择,在基础层,其中WS-*是有意义的(安全,策略等)。
RESTful:一个更好的网站集成的选择,公共API,在层的顶部(VIEW,即javascript调用uri)。
其他回答
如果您正在寻找不同系统和语言之间的互操作性,我肯定会选择REST。例如,在尝试让SOAP在. net和Java之间工作时,我遇到了很多问题。
我写的大多数应用程序都是服务器端c#或Java,或者WinForms或WPF中的桌面应用程序。这些应用程序往往需要比REST所能提供的更丰富的服务API。另外,我不想在创建web服务客户机上花费超过几分钟的时间。WSDL处理客户端生成工具允许我实现我的客户端并继续添加业务价值。
现在,如果我为一些javascript ajax调用显式地编写web服务,它可能是在REST中;只是为了了解客户端技术和利用JSON。在我看来,从javascript中使用的web服务api可能不应该非常复杂,因为这种类型的复杂性似乎可以更好地处理服务器端。
也就是说,javascript有一些SOAP客户端;我知道jQuery有一个。因此,SOAP可以从javascript中利用;只是不像REST服务返回JSON字符串那样好。因此,如果我有一个web服务,我希望它足够复杂,能够灵活地适应任意数量的客户端技术和用途,那么我会选择SOAP。
1.从我的经验来看。我想说REST让你可以选择访问已经构建好的URL。>一个词搜索谷歌。该URL可以用作REST的web服务。 在SOAP中,您可以创建自己的web服务并通过SOAP客户机访问它。
REST支持文本、JSON、XML格式。因此,两个应用程序之间的通信更加通用。而SOAP仅支持XML格式的消息通信。
快速了解一下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
这是个好问题……我不想让你误入歧途,所以我和你一样愿意接受别人的答案。对我来说,这实际上归结于开销成本和API的使用。在创建客户端软件时,我更喜欢使用web服务,但是我不喜欢SOAP的重量。我相信REST的重量更轻,但我不太喜欢从客户的角度使用它。
我很好奇别人是怎么想的。