开发人员对WCF编程理解讲述

开发 后端
WCF编程有很多值得学习的地方,这里我们主要介绍WCF编程,包括介绍WCF编程等方面。在向大家详细介绍WCF编程之前,首先让大家了解下WCF编程。

在后台运行WCF编程应用程序。出现提示后,单击OK按钮激活Web.config中的调试功能。在控制台应用程序窗口中输入一个数字,按下回车键,如下图所示显示一个简单的WCF服务和客户程序。

试试看:一个简单的WCF服务和客户程序#t#

(1) WCF编程:在目录C:BegVCSharp\Chapter35下创建一个新的WCF服务应用程序项目Ch35Ex01

(2)WCF编程: 在解决方案中添加一个控制台应用程序Ch35Ex01Client。

(3) WCF编程:在Build菜单上单击Build Solution选项。

(4)WCF编程: 在Solution Explorer中右击Ch35Ex01Client,选择Add Service Reference选项。

(5)WCF编程; 在Add Service Reference对话框中,单击Discover。

(6)WCF编程: 开始开发Web服务器,加载WCF服务的信息后,展开该引用,查看其细节,如图

35-2

(7) WCF编程:单击OK按钮,添加服务引用。

(8)WCF编程: 在Ch35Ex01Client应用程序中修改Pragram.cs中的代码,如下所示:

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using Ch35Ex01Client.ServiceReference1;  
  6. namespace Ch35Ex01Client  
  7. {  
  8. class Program  
  9. {  
  10. static void Main(string[] args)  
  11. {  
  12. string numericInput = null;  
  13. int intParam;  
  14. do  
  15. {  
  16. Console.WriteLine(  
  17. "Enter an integer and press enter to call the WCF service.");  
  18. numericInput = Console.ReadLine();  
  19. }  
  20. while (!int.TryParse(numericInput, out intParam));  
  21. Service1Client client = new Service1Client();  
  22. Console.WriteLine(client.GetData(intParam));  
  23. Console.WriteLine("Press an key to exit.");  
  24. Console.ReadKey();  
  25. }  
  26. }  

责任编辑:chenqingxiang 来源: 计世网
相关推荐

2021-02-19 09:33:01

kubernetesJAVA服务

2012-07-12 00:09:34

2020-08-14 08:11:17

编程语言PythonIT

2017-11-01 15:03:37

超级计算机编程

2009-12-25 10:11:22

.NET Framew

2010-02-02 16:07:17

Python开发人员

2012-02-15 09:17:02

Python编程

2023-10-13 18:10:14

编程语言Rust

2012-05-30 15:15:42

ibmdw

2023-03-15 07:12:53

企业开发人员提供商

2009-12-11 14:50:14

Visual Basi

2009-11-23 20:07:51

ibmdw开发

2020-05-11 10:25:38

编程语言J开发Python

2023-08-30 08:01:37

前端CSS

2023-05-22 14:57:47

2013-12-23 15:46:42

2011-09-05 14:21:29

webOS

2013-04-15 10:00:09

程序员

2009-05-31 08:31:07

GoogleWaveTechCrunch

2023-08-14 15:23:37

点赞
收藏

51CTO技术栈公众号