解决方法
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的论文枚举.