有人能用通俗易懂的英语解释一下什么是REST,什么是SOAP吗?Web服务是如何工作的?
当前回答
这是你能找到的最简单的解释。
这篇文章以丈夫对妻子的叙述为例,丈夫用纯外行的语言向妻子解释REST。一定要读!
如何向我的妻子解释休息(原始链接) 如何向妻子解释休息(2013-07-19工作链接)
其他回答
REST是一种用于设计网络应用程序的体系结构风格。其思想是,使用简单的HTTP在机器之间进行调用,而不是使用复杂的机制(如CORBA、RPC或SOAP)来连接机器。
我想这是我能解释得最简单的了。请,任何人都欢迎纠正我或补充这一点。
SOAP是一种消息格式,用于断开连接的系统(如通过internet)交换信息/数据。它处理来回的XML消息。
Web服务传输或接收SOAP消息。它们的工作方式因所用语言不同而不同。
SOAP的问题在于它与HTTP栈背后的理想相冲突。任何中间件都应该能够在不了解请求或响应内容的情况下处理HTTP请求,但例如,常规的HTTP缓存服务器如果不知道SOAP内容的哪些部分与缓存有关,则无法处理SOAP请求。SOAP只是使用HTTP作为它自己的通信协议的包装器,就像代理一样。
这两种方法都被许多大型公司采用。这是个人喜好的问题。我更喜欢REST,因为它更容易使用和理解。
简单对象访问协议(SOAP):
SOAP builds an XML protocol on top of HTTP or sometimes TCP/IP. SOAP describes functions, and types of data. SOAP is a successor of XML-RPC and is very similar, but describes a standard way to communicate. Several programming languages have native support for SOAP, you typically feed it a web service URL and you can call its web service functions without the need of specific code. Binary data that is sent must be encoded first into a format such as base64 encoded. Has several protocols and technologies relating to it: WSDL, XSDs, SOAP, WS-Addressing
具象状态转移(REST):
REST need not be over HTTP but most of my points below will have an HTTP bias. REST is very lightweight, it says wait a minute, we don't need all of this complexity that SOAP created. Typically uses normal HTTP methods instead of a big XML format describing everything. For example to obtain a resource you use HTTP GET, to put a resource on the server you use HTTP PUT. To delete a resource on the server you use HTTP DELETE. REST is a very simple in that it uses HTTP GET, POST and PUT methods to update resources on the server. REST typically is best used with Resource Oriented Architecture (ROA). In this mode of thinking everything is a resource, and you would operate on these resources. As long as your programming language has an HTTP library, and most do, you can consume a REST HTTP protocol very easily. Binary data or binary resources can simply be delivered upon their request.
在谷歌上有关于REST和SOAP的无休止的争论。
我最喜欢的是这个。 2013年11月27日更新:保罗·普莱斯科德的网站似乎已经下线,这篇文章不再可用,不过可以在Wayback Machine上找到副本,或者在CiteSeerX上以PDF格式找到。
SOAP -“简单对象访问协议”
SOAP是一种在Internet上传输消息或少量信息的简单方法。SOAP消息是XML格式的,通常在发送时控制HTTP。
REST -“具象状态传输”
REST是风扇和服务器之间的可能性和接收信息的基本过程,它没有明确定义许多标准。您可以以JSON、XML甚至纯文本的形式发送和接受信息。与SOAP相比,它是轻量级的。
推荐文章
- 用Spring我可以做一个可选的路径变量吗?
- 哪个HTTP状态代码表示“尚未准备好,稍后再试”?
- Django REST框架:向ModelSerializer添加额外字段
- REST和RPC之间的Web服务差异
- REST DELETE真的是幂等的吗?
- 如何用node.js实现一个安全的REST API
- 如何在Node.js内进行远程REST调用?旋度吗?
- Rails new vs create
- 如何使用邮差导出具体要求文件?
- 有没有REST api的命名规范指南?
- 什么是HTTP中的“406-不可接受的响应”?
- 哪些HTTP方法与哪些CRUD方法相匹配?
- 如何从iPhone访问SOAP服务
- RESTful服务中部分更新的最佳实践
- JAX-RS / Jersey如何自定义错误处理?