问题描述
可能的重复:
SOAP 或 REST
为什么我们需要 RESTful Web 服务?
大家好,
最近,经常提到 REST Web 服务.使用它而不是其他方法的原因是什么?它们是否用于 WCF &我们如何实施?
lately, the REST web services is mentioned a lot. What is the reason for using it over other methods? Are they used in WCF & how do we implement one?
TIA
推荐答案
REST 是一个经常被误解的术语.确切的定义当然可以在 Fielding 的 论文 中找到,并尝试在 维基百科条目中进行解释.简而言之,它是一种架构风格,在技术上与 HTTP 或 Web 无关.然而,HTTP 和许多网络支持并遵循 REST 架构风格.
REST is an oft misunderstood term. The precise definition can of course be found in Fielding's dissertation, and is attempted explained in the Wikipedia entry. In short it's an architectural style, and has nothing technically to do with HTTP or the web. HTTP and a lot of the web, however enable and follow the REST architectural style.
但实际上,REST 一词已被淡化,现在几乎与某种基于 HTTP 的 API 同义.
But in truth the term REST has been watered down and it now is almost synonymous with HTTP based API of some sort.
当开发人员谈论实现或使用 REST API 时,他们通常指的是为他们的所有资源记录 URI 模板,并使用 GET 检索某些内容、PUT 修改某些内容、DELETE 删除某些内容和 POST 执行任何操作其他(例如创建或接受或修改某些内容),例如 Twitter更新状态的 API 或 StackOverflow 自己的 API 或 Facebook 的 API.
When developers talk about implementing or using a REST API they usually mean something along the lines of documenting URI templates for all their resources, and use GET to retrieve something, PUT to modify something, DELETE to delete something and POST to do anything else (like create or accept or modify something), like the Twitter API to update ones status or StackOverflow's own API or Facebook's API.
这些 API 通常是
- 为系统中的每个有趣的事物(资源)提供自己的 URI
- 在这些 URI 上使用统一接口"(GET、PUT、POST、DELETE)来处理资源
- 使用标准类型的身份验证方案(例如 OAuth 或 OpenID 甚至更简单的变体)
- 是无状态的,因为每个请求都独立于任何先前的请求
所有这些都很好,并且是 REST 架构所必需的,但仅靠学术上的 REST 是不够的
All these are good, and required of REST architectures, but alone aren't enough to follow the academic REST
我认为这是对 REST 的恰当描述,就像现在一样.有一些人了解Corporate REST 和Academic REST 之间的区别,但他们的人数正在减少.
I think this is a fitting description for REST as it is now. There are a few people who understand the difference between Corporate REST and Academic REST but their numbers are dwindling.
但这是另一个问题的主题,只需搜索 HATEOAS.
But that's the topic of another question, just search for HATEOAS.
这篇关于什么是 REST Web 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!