How to: Create a Windows Communication Foundation Client

To create a Windows Communication Foundation client

  1. Create a new console application project by right-clicking on the Getting Started solution, selecting, Add, New Project. In the Add New Project dialog on the left hand side of the dialog select Windows under C# or VB. In the center section of the dialog select Console Application. Name the project GettingStartedClient.

  2. Set the target framework of the GettingStartedClient project to .NET Framework 4.5 by right clicking on GettingStartedClient in the Solution Explorer and selecting Properties. In the dropdown box labeled Target Framework select .NET Framework 4.5. Setting the target framework for a VB project is a little different, in the GettingStartedClient project properties dialog, click the Compile tab on the left-hand side of the screen, and then click the Advanced Compile Options button at the lower left-hand corner of the dialog. Then select .NET Framework 4.5 in the dropdown box labeled Target Framework.

    Setting the target framework will cause Visual Studio 2011 to reload the solution, press OK when prompted.

  3. Add a reference to System.ServiceModel to the GettingStartedClient project by right-clicking the Reference folder under the GettingStartedClient project in Solution Explorer and select Add Reference. In the Add Referencedialog select Framework on the left-hand side of the dialog. In the Search Assemblies textbox, type in System.ServiceModel. In the center section of the dialog select System.ServiceModel, click the Add button, and click the Close button. Save the solution by clicking the Save All button below the main menu.

  4. Next you wlll add a service reference to the Calculator Service. Before you can do that, you must start up the GettingStartedHost console application. Once the host is running you can right click the References folder under the GettingStartedClient project in the Solution Explorer and select Add Service Reference and type in the following URL in the address box of the Add Service Reference dialog: http://localhost:8000/ServiceModelSamples/Service and click the Go button. The CalculatorService should then be displayed in the Services list box, Double click CalculatorService and it will expand and show the service contracts implemented by the service. Leave the default namespace as is and click the OK button.

When you add a reference to a service using Visual Studio a new item will appear in the Solution Explorer under the Service References folder under the GettingStartedClient project. If you use the ServiceModel Metadata Utility Tool (Svcutil.exe) tool a source code file and app.config file will be generated.

You can also use the command-line tool ServiceModel Metadata Utility Tool (Svcutil.exe) with the appropriate switches to create the client code. The following example generates a code file and a configuration file for the service. The first example shows how to generate the proxy in VB and the second shows how to generated the proxy in C#:

You have now created the proxy that the client application will use to call the calculator service. Proceed to the next topic in the series: How to: Configure a Basic Windows Communication Foundation Client

How to: Configure a Basic Windows Communication Foundation Client

How to: Use a Windows Communication Foundation Client

创建WCF的客户端的更多相关文章

  1. WCF开发实战系列五:创建WCF客户端程序

    WCF开发实战系列五:创建WCF客户端程序 (原创:灰灰虫的家http://hi.baidu.com/grayworm) 在前面的三篇文章中我们分别介绍了WCF服务的三种载体:IIS.Self-Hos ...

  2. WCF入门教程(二)如何创建WCF服务

    WCF入门教程(二)从零做起-创建WCF服务 通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK默认创建的样本 1.创建WCF服务库 2.看其生成结构 1)IService1.cs(协议) ...

  3. 重温WCF之WCF传输安全(十三)(4)基于SSL的WCF对客户端采用证书验证(转)

    转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/20/2695397.html 前一篇我们演示了基于SSL的WCF 对客户端进行用户名和密码方式的 ...

  4. Wcf for wp8 创建wcf服务 连接wp8模拟器并显示来自wcf服务的接口信息 (一)

    下载: vs2012 pro for wp8 iis express http://download.microsoft.com/download/B/2/8/B2801FEE-9A60-4AFA-8 ...

  5. WCF入门教程(二)从零做起-创建WCF服务

    通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK默认创建的样本 1.创建WCF服务库 2.看其生成结构 1)IService1.cs(协议) 定义了协议,具体什么操作,操作的参数和返回值 ...

  6. SharePoint 2013创建WCF REST Service

    SharePoint 2013为开发者提供了丰富的REST API,方便了我们在客户端操作List中的数据.当然我们也可以在SharePoint 2013中创建自定义的REST Service,比如通 ...

  7. WCF 创建WCF

    一.概述 Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,可以翻译为Windows通讯接口,它是.NET框架的一部分.由 .NE ...

  8. 快速创建WCF服务和svcutil.exe工具使用

    先简单的创建WCF服务: 系统会自动加上IService1接口 和 Service1 实现类 分别在IService1 和Service1 加上2段代码. [ServiceContract] publ ...

  9. WebService及WCF获取客户端IP,端口

    wcf获取客户端IP,端口 var context = OperationContext.Current; var properties = context.IncomingMessageProper ...

随机推荐

  1. 怎样向IT行业的朋友说明《圣经》的重要性

    “世界的官方文档”——怎么样?

  2. C#常量字段

    const 常量字段使用方法 using System;using System.Collections.Generic;using System.Linq;using System.Text;usi ...

  3. 轮子来袭 vJine.Core Orm 之 03_架构分析

    1.vJine.Core ORM 架构: 如上图所示,vJine.Core ORM的特点如下: 所有操作均以DataManager为核心: DataManager业务部分的增删改查操作依赖于Class ...

  4. net下 Mysql Linq的使用, 更新数据,增加数据,删除数据

    net下访问mysql主要有2种方法: 1.字符串拼接访问 a.mysql官网下载并安装mysql-connector-net. b项目中引用mysql.data等 所有增删改查可以通过拼接sql语句 ...

  5. 转 Java中Filter、Servlet、Listener的学习

      1.Filter的功能filter功能,它使用户可以改变一个 request和修改一个response. Filter 不是一个servlet,它不能产生一个response,它能够在一个requ ...

  6. 什么是SQL statement?

    什么是SQL statement? 1.SQL SELECT statement - SELECT命令 REFER: What is SQL, and what are some example st ...

  7. 转载:一句代码改变Swing难看的字体

    Swing 皮肤的一个键值:swing.boldMetal 默认为 true因此造成了默认字体极度难看: 其实一句代码就能解决问题:UIManager.put("swing.boldMeta ...

  8. 数独的C++解法

    grid.h #ifndef _GRID_H_ #define _GRID_H_ #include <set> #include <cstddef> class Grid { ...

  9. 【安装操作系统】VMware 中安装 Redhat 5

    引言 已有一台 Windows XP 家用机,安装 Linux 虚拟机,一不小心就会走弯路,因此本文提供一些入门级的经验来帮助你躲开歧途. 欢迎来到 lovickie 的博客 http://www.c ...

  10. JavaScript的事件监听、捕获和冒泡

    在前端开发中,我们经常需要对某些事件进行监听.这样只要在指定的元素上触发了该事件,就会执行一个回调函数来进行相关的操作. 而JavaScript中事件监听的方法总共有三种,分别如下: element. ...