微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Web服务 – REST(RESTful)Web服务是否与HTTP绑定(耦合或需要)?

标题基本上都说明了,REST真的与HTTP绑定还是协议无关?
因为我刚读了几篇关于REST的文章,所以我遇到了两个意见,所以我不知道哪一个是正确的.

解决方法

请允许我引用 “RESTful Web Services”这本书(粗体是我的):

The Story of the REST

REST is simple,but it’s well defined and not an
excuse for implementing web services as half-assed web sites because
“they’re the same.” Unfortunately,until Now the main REST reference
was chapter five of Roy Fielding’s 2000 Ph.D. dissertation,which is a
good read for a Ph.D. dissertation,but leaves most of the real-world
questions unanswered. That’s because it presents REST not as an
architecture but as a way of judging architectures.
The term “RESTful”
is like the term “object-oriented.” A language,a framework,or an
application may be designed in an object-oriented way,but that
doesn’t make its architecture the object-oriented architecture. Even
in object-oriented languages like C++ and Ruby,it’s possible to write
programs that are not truly object-oriented. HTTP in the abstract does
very well on the criteria of REST.
(It ought to,since Fielding
co-wrote the HTTP standard and wrote his dissertation to describe the
architecture of the Web.) But real web sites,web applications,and
web services often betray the principles of REST. (…)

请注意,在第二个粗体中,他说:“HTTP非常适合REST”,而不是“REST适合/依赖于HTTP”.

因此,简而言之:不,术语“REST”不一定与HTTP相关联. RESTful Web服务只是遵循RESTful架构的Web服务,希望实现Fielding在其论文中列出的好处(例如无状态,可寻址性等).

创建RESTful Web服务的一种方法是根据资源(而不是SOAP样式使用的操作)来考虑应用程序.结合正确使用HTTP(其方法和状态代码)的这种思维方式可以导致支持REST的架构(并且具有所有好处)Fielding的论文枚举.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐