REST Web服务和区别 [英] Difference between REST and WebServices

查看:180
本文介绍了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 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.

我们使用大量的透明的.NET SOAP的,但是我只是想知道是不是真的值得付出注意力放在休息的地方都目前正在运行流畅出色。

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

我知道REST是一种架构和SOAP是一个协议,但我的问题是细节,是目前ASP.NET的WebService实现SOAP有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是作为XML通过HTTP发送/接收数据的协议。

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.

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

Typically this will be something like (for .net):


  • HTTP POST到的 mysite.com/products.asmx/ListAllProducts 的 - 返回的XML产品列表

  • HTTP POST到的 mysite.com/products.asmx/GetProduct 的 - 返回基于SOAP的XML张贴的内容的XML产品

  • HTTP POST到的 mysite.com/products.asmx/UpdateProduct 的 - 改变基于SOAP的XML张贴的内容产品

  • Http POST to mysite.com/products.asmx/ListAllProducts - returns XML list of products
  • Http POST to mysite.com/products.asmx/GetProduct - returns XML for product based on SOAP XML in the posted content
  • Http POST to mysite.com/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:


  • 的Http得到的 mysite.com/products 的 - 返回XML或JSON列出所有产品

  • 的Http得到的 mysite.com/products/14 的 - 产品14
  • 返回XML或JSON
  • HTTP POST到的 mysite.com/products/14 的 - 改变产品14到你的HTML表单张贴的内容

  • Http GET from mysite.com/products - returns XML or JSON listing all products
  • Http GET from mysite.com/products/14 - returns XML or JSON for product 14
  • Http POST to mysite.com/products/14 - changes product 14 to what you post in the HTML form.

所以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更进一步,因此,最好可以如下:

REST goes further, so ideally the following would work:


  • HTTP DELETE来的 mysite.com/products/14 的 - 删除产品14

  • HTTP PUT到的 mysite.com/products 的 - 增加了一个新产品

  • Http DELETE to mysite.com/products/14 - removes product 14
  • Http PUT to mysite.com/products - adds a new product

可惜没有实现这些HTTP动词,所以你必须依靠GET和POST对于现在的大多数浏览器。

Unfortunately the majority of browsers don't implement these HTTP verbs, so you have to rely on GET and POST for now.

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

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