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

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中的代码,如下所示:

复制

using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using Ch35Ex01Client.ServiceReference1;  namespace Ch35Ex01Client  {  class Program  {  static void Main(string[] args)  {  string numericInput = null;  int intParam;  do  {  Console.WriteLine(  "Enter an integer and press enter to call the WCF service.");  numericInput = Console.ReadLine();  }  while (!int.TryParse(numericInput, out intParam));  Service1Client client = new Service1Client();  Console.WriteLine(client.GetData(intParam));  Console.WriteLine("Press an key to exit.");  Console.ReadKey();  }  }  } 
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

  • 16.

  • 17.

  • 18.

  • 19.

  • 20.

  • 21.

  • 22.

  • 23.

  • 24.

  • 25.

  • 26.

  • 27.

12    2009-12-07 16:07:19    WCF编程