none
为什么需要Rest服务? RRS feed

答案

全部回复

  • I assume what you mean by "normal"  web services are web services using SOAP protocol (the default WCF service uses SOAP)?  If you're pretty familiar with what a SOAP web service is like, these are a few differences with the REST paradigm and the SOAP/RPC paradigm:

    • SOAP sees HTTP only as a transport layer, whose job is only to deliver messages with its "SOAP envelope".  It is the SOAP envelope that provides the elements that have rich semantics.  However, REST is a way of thinking that involves using everything HTTP has to offer.  While a SOAP web service may only care about HTTP status code and nothing else about HTTP, a REST web service care about the HTTP method used, the HTTP headers and their meanings, content type negotiation, HTTP authentication methods, etc.  REST acknowledges and utilizes HTTP's rich set of features instead of ignoring them and using some other message envelope.
    • SOAP paradigm focuses on "remote procedure call" / executing an operation on a remote service and getting the result back.  The REST paradigm focuses on creating, updating, retrieving, and deleting resources.  A SOAP operation may look like "GetOrdersForCustomerId(x)", "PublishPage(page1)".  A REST operation may look like "GET /orders/142", "PUT /orders/142", "POST /orders".  SOAP uses its own verb and noun, but REST uses HTTP methods as verbs, and URI as nouns.
    • Due to the complexity of SOAP envelope, the code for a SOAP client typically needs to be auto-generated by some tools, given the .wsdl metadata.  REST is much simpler and more transparent (no extraneous envelope), so anyone who can make a standard HTTP call can pretty much interact with a REST web service without much trouble.

    In fact REST is what everybody has been doing since the founding of the web.  When you access this forum, your browser basically does a REST call: "GET /t/1560141.aspx", instead of doing some SOAP call "DisplayPage()" or something like that.  So I think the reason we need REST services is because this is how the founding fathers of HTTP wants HTTP to be used, because we want HTTP to be harnessed to its full potential, and because ... it's simple :)

    I hope this helps

    参考 http://forums.asp.net/p/1560141/3894812.aspx


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    老徐的博客】:http://www.cnblogs.com/frank_xl/

    【WCF中文技术论坛】:微软WCF中文技术论坛
    【WCF英文技术论坛】:微软WCF英文技术论坛

    2010年6月17日 15:35
    版主
  • [编辑] REST的优点

    • 可以利用缓存Cache来提高响应速度
    • 通讯本身的无状态性可以让不同的服务器的处理一系列请求中的不同请求,提高服务器的扩展性
    • 浏览器即可作为客户端,简化软件需求
    • 相对与其他叠加在HTTP协议之上的机制,REST的软件依赖性更小
    • 不需要额外的资源发现机制
    • 在软件技术演进中的长期的兼容性更好

    http://zh.wikipedia.org/zh-cn/REST


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    老徐的博客】:http://www.cnblogs.com/frank_xl/

    【WCF中文技术论坛】:微软WCF中文技术论坛
    【WCF英文技术论坛】:微软WCF英文技术论坛

    2010年6月17日 15:38
    版主