本文转自:https://msdn.microsoft.com/zh-tw/library/dd728282(v=vs.103).aspx

WCF Data Services 5.0
 
其他版本
 

You can access a service that exposes an Open Data Protocol (OData) feed by supplying a URI to a Web browser. The URI provides the address of a resource, and request messages are sent to these addresses to access or change the underlying data that the resource represents. The browser issues an HTTP GET command and returns the requested resource as an OData feed. For more information, see Accessing OData Feeds from a Web Browser (WCF Data Services Quickstart).

Although a Web browser may be useful for testing that an OData service returns the expected data, production OData services that enable you to also create, update, and delete data are generally accessed by application code or scripting languages in a Web page. This topic provides an overview of how to access OData feeds from a client application.

OData helps guarantee interoperability between services that expose OData feeds and applications that consume OData feeds. Applications access and change data in an OData-based service by sending request messages of a specific HTTP action and with a URI that addresses an entity resource against which the action should be performed. When entity data must be supplied, it is supplied as a specifically encoded payload in the body of the message.

HTTP Actions

OData supports the following HTTP actions to perform create, read, update, and delete operations on the entity data that the addressed resource represents:

  • HTTP GET - This is the default action when a resource is accessed from a browser. No payload is supplied in the request message, and a response method with a payload that contains the requested data is returned.

  • HTTP POST - Inserts new entity data into the supplied resource. Data to be inserted is supplied in the payload of the request message.The payload of the response message contains the data for the newly created entity. This includes any autogenerated key values. The header also contains the URI that addresses the new entity resource.

  • HTTP DELETE - Deletes the entity data that the specified resource represents. A payload is not present in the request or response messages.

  • HTTP PUT - Replaces existing entity data at the requested resource with new data that is supplied in the payload of the request message.

  • HTTP MERGE - Because of inefficiencies in executing a delete followed by an insert in the data source just to change entity data, OData introduces a new HTTP MERGE action. The payload of the request message contains the properties that must be changed on the addressed entity resource. Because HTTP MERGE is not defined in the HTTP specification, it may require additional processing to route a HTTP MERGE request through non-OData aware servers.

For more information, see OData: Operations.

Payload Formats

For an HTTP PUT, HTTP POST, or HTTP MERGE request, the payload of a request message contains the entity data that you send to the data service. The contents of the payload depend on the data format of the message. The HTTP responses to all actions except DELETE also contain such a payload. OData supports the following payload formats for accessing and changing data with the service:

  • Atom - An XML-based message encoding that is defined by OData as an extension to the Atom Publishing Protocol (AtomPub) to enable data exchange over HTTP for Web feeds, podcasts, wikis, and XML-based Internet functionality. For more information, see OData: Atom Format.

  • JSON - JavaScript Object Notation (JSON) is a lightweight data interchange format that is based on a subset of the JavaScript Programming Language. For more information, see OData: JSON Format.

The message format of the payload is requested in the header of the HTTP request message. For more information, see OData: Operations.

WCF Data Services includes client libraries that enable you to more easily consume an OData feed from .NET Framework and Silverlight-based client applications. These libraries simplify sending and receiving HTTP messages. They also translate the message payload into CLR objects that represent entity data. The client libraries feature the two core classes DataServiceContext and DataServiceQuery<TElement>.These classes enable you to query a data service and then work with the returned entity data as CLR objects. For more information, see Data Client (WCF Data Services) and WCF Data Services (Silverlight).

You can use the Add Service Reference dialog in Visual Studio to add a reference to a data service. This tool requests the service metadata from a referenced data service and generates the DataServiceContext that represents a data service, as well as generates the client data service classes that represent entities. For more information, see Generating the Client Data Service Classes (WCF Data Services).

There are programming libraries available that you can use to consume an OData feed in other kinds of client applications. For more information, see the OData SDK.

[转]Consuming a OData Service in a Client Application (WCF Data Services)的更多相关文章

  1. [转]WCF Data Services OData

    http://martinwilley.com/net/data/wcfds.html WCF Data Services About OData Server code Client For .ne ...

  2. 为 Oracle Database 开发 WCF Data Services 和 OData 应用程序

    为 Oracle Database 开发 WCF Data Services 和 OData 应用程序 本教程包含以下部分:   目的   所需时间   概述   先决条件   创建新的网站项目   ...

  3. WCF Data Services 5.0 for OData V3

    https://www.microsoft.com/en-us/download/details.aspx?id=29306 VS 2010 下 安装 WCF Data Services 5.0 en ...

  4. [转]访问 OData 服务 (WCF Data Services)

    本文转自:http://msdn.microsoft.com/zh-SG/library/dd728283(v=vs.103) WCF 数据服务 支持开放式数据协议 (OData) 将数据作为包含可通 ...

  5. [转]Calling an OData Service From a .NET Client (C#)

    本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata- ...

  6. WCF Data Service 使用小结(二) —— 使用WCF Data Service 创建OData服务

    在 上一章 中,介绍了如何通过 OData 协议来访问 OData 服务提供的资源.下面来介绍如何创建一个 OData 服务.在这篇文章中,主要说明在.NET的环境下,如何使用 WCF Data Se ...

  7. 使用WCF Data Service 创建OData服务

    使用WCF Data Service 创建OData服务 在 上一章 中,介绍了如何通过 OData 协议来访问 OData 服务提供的资源.下面来介绍如何创建一个 OData 服务.在这篇文章中,主 ...

  8. Consuming a Web Service in AX 2012

    Consuming a Web Service in AX 2012 在AX2012版本中如果想调用外部的Web Service变得非常容易. 第一步,在VS中创建一个Web Service并发布 第 ...

  9. WCF Data Service 使用小结 (一)—— 了解OData协议

    最近做了一个小项目,其中用到了 WCF Data Service,之前是叫 ADO.NET Data Service 的.关于WCF Data Service,博客园里的介绍并不多,但它确实是个很好的 ...

随机推荐

  1. 一行代码搞定Dubbo接口调用

    本文来自网易云社区 作者:吕彦峰 在工作中我们经常遇到关于接口测试的问题,无论是对于QA同学还是开发同学都会有远程接口调用的需求.针对这种问题我研发了一个工具包,专门用于远程Dubbo调用,下面就让我 ...

  2. “全栈2019”Java第三十九章:构造函数、构造方法、构造器

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  3. scrapy框架post请求发送,五大核心组件,日志等级,请求传参

    一.post请求发送 - 问题:爬虫文件的代码中,我们从来没有手动的对start_urls列表中存储的起始url进行过请求的发送,但是起始url的确是进行了请求的发送,那这是如何实现的呢? - 解答: ...

  4. [ActionScript 3.0] flash中的颜色

    在 Flash 中,颜色就是一串特殊的数字,一个颜色值可以是0到16,777,215中的任意数值,这就是24位(bit)色彩.也许大家会问,为什么有16,777,216(256*256*256)种颜色 ...

  5. jqury表单验证

    结合天天生鲜的用户注册页面,学习验证表单js register.js--表单验证源码 $(function(){ var error_name = false; var error_password ...

  6. python3入门之集合set

    之前介绍python的数据结构时,没有介绍set(集合)现在在这里稍微介绍下: set原理 Python 还 包 含 了 一 个 数 据 类 型-- set ( 集 合 ) . 集 合 是 一 个 无 ...

  7. 关于OC中的block自己的一些理解(二)

    一.block延伸:页面间反向传值 1)first页面的代码 - (void)viewDidLoad { [super viewDidLoad]; [self setupBtn]; self.view ...

  8. 利用腾讯云为你的域名申请并配置免费SSL一年

    我想,点进来的朋友,应该都知道SSL的重要性吧.这里就简单提一下,大型网站域名只有配置了SSL后,才会更加安全. 现在,微信小程序也开始要求后台必须是SSL配置后的域名了.说了这么多,估计有些人还是有 ...

  9. 01迷宫 BFS

    题目描述 有一个仅由数字000与111组成的n×nn \times nn×n格迷宫.若你位于一格0上,那么你可以移动到相邻444格中的某一格111上,同样若你位于一格1上,那么你可以移动到相邻444格 ...

  10. 机器学习中的范数规则化之 L0、L1与L2范数、核范数与规则项参数选择

    装载自:https://blog.csdn.net/u012467880/article/details/52852242 今天我们聊聊机器学习中出现的非常频繁的问题:过拟合与规则化.我们先简单的来理 ...