REST 和 Web 服务之间的区别

编程入门 行业动态 更新时间:2024-10-27 01:34:59
本文介绍了REST 和 Web 服务之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

REST 和 WebService (SOAP) 之间有什么区别,我查看了 facebook api,它们使用 HTTP 标头和一些参数(可能是 xml 或非)并以 xml 格式返回结果,否则 SOAP 完全相同,HTTP 标头 +xml 参数并返回标题 + xml.

What is difference between REST and WebService (SOAP), I looked at the facebook api, they use HTTP headers and some parameters (probably xml or non) and return result in xml, where else SOAP does exactly same, HTTP headers + xml parameters and returns headers + xml.

REST 还需要一些经过身份验证的令牌,否则 SOAP 使用 http 会话,这与用于身份验证和其他信息的令牌完全相同.我只能看到 SOAP 是 REST 的高级版本吗?

REST also requires some authenticated token where else SOAP uses http session which is exactly same token used for auth and other information. All I can see that SOAP is little advanced version of REST?

或者还有其他性能方面的考虑吗?阅读有关 REST 的内容只是谈论非常高级别的客户端服务器通信,但即使是 SOAP 也完全相同.谁能告诉我它可以定义正确的 REST 和 SOAP 边界.

Or are there any other performance considerations? Reading about REST just talks very high level of client server communication but even SOAP does exactly same. Can anyone point me where it can define correct boundry of REST and SOAP.

我们在 中透明地使用了大量 SOAP,但是我只想知道是否真的值得关注 REST,目前一切运行都非常流畅.

We use lot of SOAP transparently in , however I just want to know is it really worth paying attension to REST where currently everything is running outstandingly smooth.

我知道 REST 是一种架构,而 SOAP 是一种协议,但我的问题是目前 SOAP 的 ASP.NET WebService 实现是否具有 REST 架构?

I know REST is an architecture and SOAP is a protocol but my question is in detail that is currently the ASP.NET WebService implementation of SOAP has REST architecture?

推荐答案

SOAP 是一种通过 HTTP 以 XML 形式发送/接收数据的协议.

SOAP is a protocol for sending/receiving data over HTTP as XML.

一个典型的 WebService 是一些方法,一个描述如何调用它的 WSDL.对于这些应该如何构建并没有真正的约定,因此您总是需要大量的 API 文档.

A typical WebService will be a few methods an WSDL that describes how to call it. There's no real convention for how these should be structured, so you always need lots of API documentation.

通常,这将类似于(对于 ASP.NET):

Typically this will be something like (for ASP.NET):

  • HTTP POST 到 mysite/products.asmx/ListAllProducts - 返回 XML 产品列表
  • HTTP POST 到 mysite/products.asmx/GetProduct - 根据发布内容中的 SOAP XML 返回产品的 XML
  • HTTP POST 到 mysite/products.asmx/UpdateProduct - 根据已发布内容中的 SOAP XML 更改产品
  • HTTP POST to mysite/products.asmx/ListAllProducts - returns XML list of products
  • HTTP POST to mysite/products.asmx/GetProduct - returns XML for product based on SOAP XML in the posted content
  • HTTP POST to mysite/products.asmx/UpdateProduct - changes product based on SOAP XML in the posted content

REST 更像是一种用于构建所有方法的约定:

REST is more of a convention for structuring all of your methods:

  • 来自 mysite/products 的 HTTP GET - 返回列出所有产品的 XML 或 JSON
  • 来自 mysite/products/14 的 HTTP GET - 返回产品 14 的 XML 或 JSON
  • HTTP POST 到 mysite/products/14 - 将产品 14 更改为您在 HTML 表单中发布的内容.
  • HTTP DELETE 到 mysite/products/14 - 删除产品 14
  • HTTP PUT 到 mysite/products - 添加新产品
  • HTTP GET from mysite/products - returns XML or JSON listing all products
  • HTTP GET from mysite/products/14 - returns XML or JSON for product 14
  • HTTP POST to mysite/products/14 - changes product 14 to what you post in the HTML form.
  • HTTP DELETE to mysite/products/14 - removes product 14
  • HTTP PUT to mysite/products - adds a new product

因此 REST 的工作方式更像您期望的浏览器 URL.这样就更自然了,作为惯例也更容易理解.所有 REST API 都以类似的方式工作,因此您无需花很长时间来了解每个系统的怪癖.

So REST works more like you'd expect browser URLs to. In that way it's more natural and as a convention is much easier to understand. All REST APIs work in a similar way, so you don't spend as long learning the quirks of each system.

更多推荐

REST 和 Web 服务之间的区别

本文发布于:2023-10-07 17:46:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470074.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   REST   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!