个人网站需要买服务器吗,WordPress博客建站系统,电子商务网站APP,saas软件把最近使用的WCF Data Service和WCF RIA Service的使用例子发布在站点http://dskit.codeplex.com #xff0c; 本系列文章就把WCF Data Service和WCF RIA Service涉及的主要方面描述一下#xff0c;希望通过这些内容#xff0c;可以比较顺畅的把这些框架使用起来#xff0c…把最近使用的WCF Data Service和WCF RIA Service的使用例子发布在站点http://dskit.codeplex.com 本系列文章就把WCF Data Service和WCF RIA Service涉及的主要方面描述一下希望通过这些内容可以比较顺畅的把这些框架使用起来以提高开发的效率。 WCF Data Services中几个基础的概念 Tenets of REST HTTP method Method information is kept in the HTTP header, not in the body of the request. Resource based Resources are expressed as “services” that clients consume. Addressability The scoping information is kept in the URL. Operations such as $filter $top $skip Relationships How the data relates to each other is expressed in ADO.NET Data Services by resource links according to the CSDL [ specified in the Entity Data Model (EDM)]. A relationship link element such as link href”Customers(‘ALFKI’)/Orders Statelessness No stateful messages are exchanged between resources MIME类型 承载的服务可以以JSON和ATOM返回【请求时说明MIME类型】用的返回类型如下 MIME MIME Type 应用程序类型 JSON application/json ASP.NET, AJAX, Silverlight Atom application/atomxml .NET Clients, Silverlight, ASP.NET mashups HTTP Operation Success Return Codes 根据REST的定义对于不同的操作定义的服务端返回值情况 Operation Success Code GET 200 OK POST 201 Created PUT 204 No- Content DELETE 204 No- Content MERGE 204 No- Content 简单例子 VS2010中新建一个WEB工程按如下步骤建立一个例子项目 建立微软SQL例子数据库NorthWind 1、 添加 Ado.net Entity: 选择SQL最初的例子NorthWind数据库 2、 添加WCF Data ServicesWcfDataService.svc 3、 在WcfDataService.svc.cs配置访问规则 config.SetEntitySetAccessRule(*, EntitySetRights.AllRead); config.SetServiceOperationAccessRule(*, ServiceOperationRights.All); config.DataServiceBehavior.MaxProtocolVersion DataServiceProtocolVersion.V2; 以上的部分是配置服务的可访问性和权限、行为等各种参数具体参考MSDN如果不对互联网公布的默认配置也可 4、服务访问测试Build解决方案后即可访问 下表是几个访问的实例 发布的服务描述 http://localhost:1206/WcfDataService.svc/ 多个实体实例 http://localhost:1206/WcfDataService.svc/Suppliers 单个实体实例 http://localhost:1206/WcfDataService.svc/Suppliers(1) 对象关系导航 http://localhost:1206/WcfDataService.svc/Suppliers(1)/Products 【工程可从http://dskit.codeplex.com下载】 可以看到发布一个数据并进行查询等处理写的代码简直是很少了而提供的功能却非常强大后续对查询等继续进行说明。