关于WCF Service相关介绍

开发 后端
本系列课程我们将会从WCF Service发布的各个角度出来,来讲述WCF Service发布以后的全新功能,这主要包括C#3.0,VB9.0,WCF,WPF,WP,LINQ,AJAX,mobile开发,Cardspace,智能客户端。

首先,我认为这是一个很有用的插件,如果继续得到改进和增强,我想该插件会被更多开发者使用。对于WCF Service源码的学习,对于我们掌握怎样正确创建WCF Service插件工程是很有帮助的,而且也可从中学到不少编程技巧,例如委托和模板方法。希望大家一起研究下

微软的 WCF Service默认会这样设置,可能如同博文所提到的,WCF Service 的客户端可能是旧版 .NET 1.x 版的环境,也可能是 Java 或其他各种非微软的技术平台,因此 VS 2008 默认选用所有厂商、所有平台都支持的 Array 数组,作为网络传输的类型,而非最新版 .NET 平台特有的 Collection 数据结构。最后,若用户端程序要再更改配置,只要如下图 5 般,在 WCF Service项目里既有的 Reference 上,选择「配置服务引用」即可。#t#

以下为本帖下载示例的代码。我们在服务器端的 WCF Service,提供三个返回类型分别为 List<string>、List<自定义类>、Dictionary<string,string> 的函数,给 WCF 客户端 ASP.NET 程序调用,执行结果:

  1. public partial class _Default : System.Web.UI.Page   
  2. {  
  3.     protected void Page_Load(object sender, EventArgs e)  
  4.     {  
  5.         ServiceReference1.ServiceClient prox = new ServiceReference1.ServiceClient();  
  6.  
  7.         /*********** List<string> ***********/  
  8.         //string[] list1 = new string[2];   //未改设置前,Server 返回的 List<string>,Client 只能取得 string 数组  
  9.         List<string> list1 = new List<string>();          
  10.         list1 = prox.getListString();  
  11.  
  12.         Response.Write(list1[0] + "<br>");  
  13.         Response.Write(list1[1] + "<p>");  
  14.  
  15.  
  16.         /*********** List<自定义类> ***********/  
  17.         List<ServiceReference1.Employee> list2 = new List<ServiceReference1.Employee>();  
  18.         list2 = prox.getListEmployee();  
  19.           
  20.         Response.Write(list2[0].name + "<br>");  
  21.         Response.Write(list2[0].age + "<br>");  
  22.         Response.Write(list2[0].oooo + "<p>");      //object 类型  
  23.  
  24.  
  25.         /*********** Dictionary<string,string> ***********/  
  26.         Dictionary<string, string> dict1 = new Dictionary<string, string>();  
  27.         dict1 = prox.getDictionaryString();  
  28.  
  29.         foreach (KeyValuePair<string, string> kvp in dict1)  
  30.         {  
  31.             Response.Write(kvp.Key + ", " + kvp.Value + "<br>");  
  32.         }  
  33.     }  
  34. }  
责任编辑:chenqingxiang 来源: 计世网
相关推荐

2009-12-08 16:42:48

WCF Service

2009-11-09 17:55:13

WCF缓存

2009-11-09 13:47:22

WCF Stream操

2009-12-21 18:10:50

WCF实现事件通知

2009-12-08 10:52:30

WCF双工通信

2009-12-24 15:04:40

ADO管理

2009-11-09 14:15:17

WCF集合类型

2009-12-08 18:14:53

WCF Service

2018-06-12 15:30:07

数据库MySQLinsert

2009-12-08 16:01:50

WCF Service

2011-04-28 15:18:59

2009-11-17 17:07:01

PHP关联数组

2009-12-22 16:03:03

WCF异常

2009-12-07 15:02:46

WCF学习

2009-11-09 13:04:53

WCF事物处理

2009-11-09 16:44:18

WCF Service

2009-12-08 17:16:37

WCF Web Ser

2009-11-06 10:11:34

WCF和Web Ser

2009-11-06 11:07:52

WCF事务属性

2009-11-05 11:31:00

WCF绑定
点赞
收藏

51CTO技术栈公众号