wcf

WCF RIA Services 快速上手

旧街凉风 提交于 2020-04-07 13:30:19
WCF RIA Services 简化开发RIA n-tier 解决方案。让你快速构建Silverlight n-tier应用程序客户端与服务端的通信。下面我们来看一张图: 下面我们来构建一个简单的DEMO: 首先,下载 Silverlight 4 Tools for Visual Studio 2010 ,建一个Silverlight project: 接下弹出对话框,记得Enable WCF RIA Services: 建立DEMO的表,并插入几条数据: 1: CREATE TABLE [dbo].[tblItem]( 2: [ItemNumber] INT NOT NULL, 3: [ItemDescription] [varchar](50) NULL, 4: [Quantity] [int] NULL 5: CONSTRAINT [PK_tblItem] PRIMARY KEY CLUSTERED 6: ( 7: [ItemNumber] ASC ) 8: ) 9: 10: INSERT INTO [tblItem] 11: ([ItemNumber] 12: ,[ItemDescription] 13: ,[Quantity]) 14: VALUES ('1','Item Name1',1), 15: ('2','Item Name2',2), 16: ('3',

一个WCF使用TCP协议进行通协的例子

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-06 08:38:52
  之前写的例子都是基于http协议的,但在局域网环境下,我希望可以获取更高的传输性能和更低的服务端资源占用,所以我尝试使用TCP协议来进行传输。网上的例子都讲得非常复杂,但终于让我找到一个简单的实现方法,记录如下: 一、建立WCF服务   首先建立一个WCF服务库,名称为"WCFService",解决方案名称为"WCFDemo",同时"为解决方案 创建目录"要勾上。         确定后VS会自动创建一个IService1接口和Service1程序文件,不过由于这个例子是演示如何使 用TCP协议的,所以我们就不再作任何修改。 二、建立宿主程序   在解决方案上按右键,选择"添加" -> "新建项目",然后新建一个Windows 窗体应用程序,程 序名称为"WCFHost"。         在解决方案资源管理器中,需要添加两个引用:System.ServiceModel和WCFService。然后双击窗口,在Form_Load事件中编写如下代码:   添加一个应用程序配置文件App.Config,然后粘贴如下内容: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <netTcpBinding> <binding name="TcpBinding"

WCF编程系列(五)元数据

删除回忆录丶 提交于 2020-04-06 08:23:53
示例一中我们使用了scvutil命令自动生成了服务的客户端代理类: svcutil http://localhost:8000/?wsdl /o:FirstServiceClient.cs 命令中 http://localhost:8000/?wsdl 连接返回一个XML,该XML即为元数据:用以描述如何与服务的终结点进行交互。正因为有元数据的存在,svcutil命令才能自动生成客户端代理类。 元数据遵循Web服务描述语言(WSDL)标准,所以可被多种语言支持,除WCF的svcutil外,Java程序员也可使用诸如WSDL2Java的工具生成Java语言的客户端代理类。 WCF服务公开自己的元数据可采用两种方案,一是使用基于HTTP-GET协议提供元数据,二是使用专门的终结点方式。 下面将讲述如何通过配置文件来公开服务的元数据 以HTTP-GET方式公开元数据: 此方法我们在我们前述示例中已经使用 1.在Host项目配置文件中,<service>配置节点中指定behaviorConfiguration值为behaviorConfiguration 2.在<behaviors><serviceBehaviors>下添加一个name属性为behaviorConfiguration的<behavior>节点 3.在<behavior>下添加子节点<serviceMetadata>

.net中的数据访问框架比较

 ̄綄美尐妖づ 提交于 2020-04-03 13:26:28
Windows平台上数据访问技术飞速发展,在现在的项目中该如何选择合适的技术且该技术能有比较长的持续周期呢? 通过查询和汇总了网上的一些资料,希望能够为我们在开发中架构选型提供帮助。 发展方向 微软官方的一个说明。 http://www.infoq.com/cn/news/2010/07/Top-10-Questions-on-Data http://msdn.microsoft.com/en-us/data/bb525059.aspx 微软宣称“会继续开发这些技术”,但不会继续使用“Oslo”这个代号,而是改名为 SQL Server Modeling CTP 。由于与SQL相关技术的紧密联系,特别是Quadrant(译注:用来查看和修改数据库中数据的工具)和Repository(现在叫做SQL Server Modeling Services),这些技术将来会被集成到SQL Server中。 微软还解释了SQL Server Modeling和.NET之间的联系:它使得创建模型驱动的应用程序更加容易。 ADO.NET Data Services和.NET RIA Services ADO.NET Data Services变成了WCF Data Services,而.NET RIA Services则变成了WCF RIA Services

WCF常见问题

£可爱£侵袭症+ 提交于 2020-04-03 11:53:37
一、创建时,WCF Service中HttpContext.Current为null的解决办法 1. 在hosting WCF的web.config中加入: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> </system.serviceModel> 2. 在Service的类定义上加上下面Attribute: [AspNetCompatibilityrequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 二、错误提示:调用方未由服务进行身份验证。 修改 WCF 服务的 config 文件 system.serviceModel下添加配置: <bindings> <wsHttpBinding> <binding name="bindingConfiguration1"> <security mode="None"> <transport clientCredentialType="None"/> <message clientCredentialType="None"/> </security> </binding> </wsHttpBinding> <

WCF常见问题

不羁岁月 提交于 2020-04-03 11:53:16
一、创建时,WCF Service中HttpContext.Current为null的解决办法 1. 在hosting WCF的web.config中加入: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> </system.serviceModel> 2. 在Service的类定义上加上下面Attribute: [AspNetCompatibilityrequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 二、错误提示:调用方未由服务进行身份验证。 修改WCF服务的 web. config 文件system.serviceModel下添加配置: <bindings> <wsHttpBinding> <binding name="bindingConfiguration1"> <security mode="None"> <transport clientCredentialType="None"/> <message clientCredentialType="None"/> </security> </binding> </wsHttpBinding> <

年前辞职-WCF入门(6)

两盒软妹~` 提交于 2020-04-03 09:06:32
前言 昨天早上去医院做入职体检,被告知要预约,本以为是要排队,我连视频都准备好了。。。结果就回来了。下午去了新公司那边找房子,2了,因为公司提供了班车列表,我既然就只在班车所经过的几个地方找,却遗漏了公司附近这个重要的地址。最后找了一个“江景房”,上阳台就能看到钱塘江。价格和现在的比翻了一倍,累了,不想找了。 有朋友让我把标题前缀“年前辞职”4个字拿了,好吧,我承认,我就是靠这个吸引一部分眼球的。 第六集 WCF DataContract & DataMember (WCF的Data和DataMember) 这些天写下来关于那个mex还是有点困惑,早上在stackoverflow上搜到一个回答,感觉写得挺好的,在此拿出来分享一下。地址: http://stackoverflow.com/questions/21522493/what-was-the-difference-between-wsdl-mex-endpoint-in-wcf 。或许如果你有WebService的经验,理解起来会更轻松一些。站在使用者的角度,我试着拿掉了endpoint有关mex的定义,以及注释了behaviors节点,然后访问 http://localhost:8080/ 页面给了我这么一个提示: 还是回到了最初。 还有一点,stackoverflow回答中向我们传递了一个意思,关于WCF

Ascertain reason for Channel Fault in WCF+NamedPipes

痴心易碎 提交于 2020-03-31 18:00:54
问题 I have a whole sequence of interlinked questions. I would like to know answers for all of them independantly, so *yes*, some of them appear to be X-Y questions; but I do want to know the solution to them anyway!. See end of question for list of other questions in this set. How do I determine the reason for a Channel Fault, e.g. caused by closing the exe on one end of a DuplexChannel connected by named pipes? I have two exes running; communicating over named pipes, via WCF. (If it's relevant,

WCF常见问题

放肆的年华 提交于 2020-03-30 07:04:48
一、创建时,WCF Service中HttpContext.Current为null的解决办法 1. 在hosting WCF的web.config中加入: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> </system.serviceModel> 2. 在Service的类定义上加上下面Attribute: [AspNetCompatibilityrequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 二、错误提示:调用方未由服务进行身份验证。 修改 WCF 服务的 web. config 文件 system.serviceModel下添加配置: <bindings> <wsHttpBinding> <binding name="bindingConfiguration1"> <security mode="None"> <transport clientCredentialType="None"/> <message clientCredentialType="None"/> </security> </binding> </wsHttpBinding> <

使用JQuery post Json对象到WCF restful service

夙愿已清 提交于 2020-03-28 02:49:21
1.首先创建一个DataContract类:Book. 2.创建BoOK类相关的service 接口IBookService及实现接口的BookService类。 3.配置部署Restful WCF service。 我们将在IBookService 接口里添加一个方法 [OperationContract] [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "SaveBook")] string SaveBook(Book book); 在BookService里重写SaveBook方法 public string SaveBook(Book book) { //此处调用保存图书实体对象到数据库的方法 //MyBookImp.SaveBook(book) return "id ="+ book.bId; } 最后使用JQuery调用WCF的SaveBook方法。 function SaveBook() { var bookData = { “bName”: “32334833425543”, “bCount”: “32” }; $.ajax({ type: “POST”, url: