web-services - REST (RESTful) Web 服务是否与 HTTP 绑定(bind)(耦合或需要)?

标签 web-services rest http protocols

标题基本上说明了一切,REST 真的与 HTTP 绑定(bind)还是独立于协议(protocol)? 因为我刚刚看了一些关于 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 services 只是遵循 RESTful 架构的 web 服务,希望能够实现 Fielding 在其论文中列出的好处(如无状态、可寻址性等)。

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

关于web-services - REST (RESTful) Web 服务是否与 HTTP 绑定(bind)(耦合或需要)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21080755/

相关文章:

java - 为 POST 请求创建自动递增的 json 对象以保存在数据库中

rest - Google Routes api X-Goog-FieldMask 不起作用

javascript - 错误: Connection lost: The server closed the connection. mysql Node

rest - 在 Unity3d 中运行 REST 服务器

PHP 响应 HEAD 请求

java - Web 服务中使用的 ElasticSearch 抛出 OverlappingFileLockException

java - tomcat运行时NoSuchMethodError如何解决?

c# - 如何访问 ApiController 中的 Response

rest - 请求参数冲突的 HTTP 状态?

c# - Linq To SQL、Web 服务、网站 - 全部规划