OData和REST-ful web服务之间的区别是什么?
当前回答
UPDATE警告,现在OData V4可用了,这个答案已经非常过时了。
不久前我在这里写了一篇关于这个主题的文章。
正如Franci所说,OData基于Atom Pub。然而,他们在上面分层了一些功能,不幸的是忽略了过程中的一些REST约束。
OData服务的查询功能要求您基于响应中不可用或链接到的信息构造uri。这就是REST人员所说的带外信息,并在客户机和服务器之间引入了隐藏耦合。
引入的另一种耦合是通过使用EDMX元数据来定义条目内容中包含的属性。这个元数据可以在一个名为$metadata的固定端点上被发现。同样,客户端需要提前知道这一点,它不能被发现。
不幸的是,微软认为不适合创建媒体类型来描述这些关键数据,因此任何OData客户端都必须对它正在通信的服务和它正在接收的数据做出一系列假设。
其他回答
ODATA是一种特殊的REST,我们可以从URL统一地查询数据。
2012年OData进行了标准化,所以我只是在这里添加了一个更新。
首先是定义:
REST——是一种如何通过HTTP发送消息的体系结构。
OData V4——是REST的一个特定实现,真正定义了不同格式的消息内容(目前我认为是AtomPub和JSON)。ODataV4遵循rest原则。
例如,asp.net开发人员将主要使用WebApi控制器将对象序列化/反序列化为JSON,并让javascript对其进行处理。Odata的关键在于能够直接从URL进行查询 开箱即用的选项。
OData协议构建在AtomPub协议之上。AtomPub协议是REST API设计的最佳示例之一。所以,在某种意义上你是对的——OData只是另一个REST API,每个OData实现都是一个REST web服务。
不同之处在于OData是一个特定的协议;REST是体系结构风格和设计模式。
REST代表具象状态传输,这是一种基于资源的架构风格。基于资源意味着数据和功能被视为资源。
OData是一个基于web的协议,它定义了一组构建和使用rest式web服务的最佳实践。OData是一种创建REST式web服务的方法,是REST的实现。
OData (Open Data Protocol) is an OASIS standard that defines the best practice for building and consuming RESTful APIs. OData helps you focus on your business logic while building RESTful APIs without having to worry about the approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats and query options etc. OData also guides you about tracking changes, defining functions/actions for reusable procedures and sending asynchronous/batch requests etc. Additionally, OData provides facility for extension to fulfil any custom needs of your RESTful APIs. OData RESTful APIs are easy to consume. The OData metadata, a machine-readable description of the data model of the APIs, enables the creation of powerful generic client proxies and tools. Some of them can help you interact with OData even without knowing anything about the protocol. The following 6 steps demonstrate 6 interesting scenarios of OData consumption across different programming platforms. But if you are a non-developer and would like to simply play with OData, XOData is the best start for you.
欲了解更多详情,请访问http://www.odata.org/
推荐文章
- ReferenceError: description没有定义NodeJs
- REST API - dto还是不是?
- OData和REST web服务的区别
- 在单元测试中设置HttpContext.Current.Session
- 用Spring我可以做一个可选的路径变量吗?
- XSD和WSDL之间的区别是什么?
- 哪个HTTP状态代码表示“尚未准备好,稍后再试”?
- Django REST框架:向ModelSerializer添加额外字段
- 火灾vs. Webservice
- REST和RPC之间的Web服务差异
- REST DELETE真的是幂等的吗?
- 如何用node.js实现一个安全的REST API
- 如何在Node.js内进行远程REST调用?旋度吗?
- Rails new vs create
- 如何使用邮差导出具体要求文件?