比较和对比 REST 和 SOAP Web 服务? [英] Compare and contrast REST and SOAP web services?

查看:63
本文介绍了比较和对比 REST 和 SOAP Web 服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前发现类似的方法是使用互联网协议 (HTTP) 在消费者和提供者之间交换数据.

I currently figure out the similar is both using internet protocol (HTTP) to exchange data between consumer and provider.

区别在于:

  1. SOAP 是一种基于 XML 的消息协议,而 REST 是一种架构风格
  2. SOAP 使用 WSDL 进行消费者和提供者之间的通信,而 REST 仅使用 XML 或 JSON 来发送和接收数据
  3. SOAP 通过调用 RPC 方法调用服务,REST 只是通过 URL 路径调用服务
  4. SOAP 不返回人类可读的结果,而 REST 结果只是简单的 XML 或 JSON 可读
  5. SOAP 不仅基于 HTTP,它还使用其他协议,例如 SMTP、FTP 等,REST 仅基于 HTTP

这就是我所知道的一切,因为它们之间的区别.任何人都可以纠正我并添加更多内容.

That's everything I know as the differences between them. Could anyone correct me and add more.

推荐答案

SOAP 使用 WSDL 进行通信 btw 消费者和提供者,而REST 只是使用 XML 或 JSON 来发送和接收数据

SOAP uses WSDL for communication btw consumer and provider, whereas REST just uses XML or JSON to send and receive data

WSDL 定义了客户端和服务之间的契约,并且本质上是静态的.在 REST 合约的情况下有点复杂,由 HTTP、URI、媒体格式和特定​​于应用程序的协调协议定义.与 WSDL 不同,它是高度动态的.

WSDL defines contract between client and service and is static by its nature. In case of REST contract is somewhat complicated and is defined by HTTP, URI, Media Formats and Application Specific Coordination Protocol. It's highly dynamic unlike WSDL.

SOAP 不返回人类可读的结果,而 REST 结果只是普通的 XML 或 JSON 可读

SOAP doesn't return human readable result, whilst REST result is readable with is just plain XML or JSON

这不是真的.纯 XML 或 JSON 根本不是 RESTful.它们都没有定义任何反对 REST 的控件(即链接和链接关系、方法信息、编码信息等),只要消息必须是自包含的,并协调代理/客户端和服务之间的交互.

This is not true. Plain XML or JSON are not RESTful at all. None of them define any controls(i.e. links and link relations, method information, encoding information etc...) which is against REST as far as messages must be self contained and coordinate interaction between agent/client and service.

使用链接 + 语义链接关系,客户端应该能够确定下一步交互步骤是什么,并遵循这些链接并继续与服务通信.

With links + semantic link relations clients should be able to determine what is next interaction step and follow these links and continue communication with service.

消息不一定是人类可读的,可以使用神秘的格式并构建完全有效的 REST 应用程序.消息是否人类可读并不重要.

It is not necessary that messages be human readable, it's possible to use cryptic format and build perfectly valid REST applications. It doesn't matter whether message is human readable or not.

因此,纯 XML(application/xml) 或 JSON(application/json) 不足以构建 REST 应用程序.使用这些具有强语义并提供足够控制信息(链接等)的通用媒体类型的子集来协调客户端和服务器之间的交互总是合理的.

Thus, plain XML(application/xml) or JSON(application/json) are not sufficient formats for building REST applications. It's always reasonable to use subset of these generic media types which have strong semantic meaning and offer enough control information(links etc...) to coordinate interactions between client and server.

REST 仅超过 HTTP

REST is over only HTTP

不正确,HTTP 使用最广泛,当我们谈论 REST Web 服务时,我们只是假设 HTTP.HTTP 定义了与其方法(GET、POST、PUT、DELETE、PATCH 等)的接口以及可以统一用于与资源交互的各种标头.这种一致性也可以通过其他协议实现.

Not true, HTTP is most widely used and when we talk about REST web services we just assume HTTP. HTTP defines interface with it's methods(GET, POST, PUT, DELETE, PATCH etc) and various headers which can be used uniformly for interacting with resources. This uniformity can be achieved with other protocols as well.

附言REST 的非常简单但非常有趣的解释:http://www.looah.com/source/view/2284

P.S. Very simple, yet very interesting explanation of REST: http://www.looah.com/source/view/2284

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

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