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

How to: Create a Windows Communication Foundation Client的更多相关文章

  1. How to: Host and Run a Basic Windows Communication Foundation Service

    This is the third of six tasks required to create a Windows Communication Foundation (WCF) applicati ...

  2. Step3 - How to: Host and Run a Basic Windows Communication Foundation Service

    This is the third of six tasks required to create a Windows Communication Foundation (WCF) applicati ...

  3. How to: Implement a Windows Communication Foundation Service Contract

    This is the second of six tasks required to create a basic Windows Communication Foundation (WCF) se ...

  4. Step2 - How to: Implement a Windows Communication Foundation Service Contract

    This is the second of six tasks required to create a basic Windows Communication Foundation (WCF) se ...

  5. How to: Define a Windows Communication Foundation Service Contract

    This is the first of six tasks required to create a basic Windows Communication Foundation (WCF) app ...

  6. Step1 - How to: Define a Windows Communication Foundation Service Contract

    https://msdn.microsoft.com/en-us/library/ms731835.aspx This is the first of six tasks required to cr ...

  7. Windows Communication Foundation (WCF)和Windows CardSpace的示例程序

    微软公司昨天发布了一个Windows Communication Foundation (WCF)和Windows CardSpace的示例程序包,内容极为丰富,从最简单的Hello World到复杂 ...

  8. 【翻译习作】 Windows Workflow Foundation程序开发-第一章02

    1.2      Windows Workflow概览 微软的Windows Workflow Foundation(简称WF)是.NET框架3.0版的一部分..NET3.0其它主要部分是Window ...

  9. Workflow-Microsoft:Windows Workflow Foundation

    ylbtech-Workflow-Microsoft:Windows Workflow Foundation 1. Windows Workflow Foundation返回顶部 1.1. Windo ...

随机推荐

  1. rac节点挂掉后,vip飘到别的节点,但是业务连接不上报 no listener问题处理

    客户一套rac系统,三节点,其中一个节点的p260主机主板有问题(经常机器重启,好像是这个型号的通病,主板被炒到20W),临时把故障节点的vip作为业务地址用. 首先,查看确定故障节点vip飘到那个节 ...

  2. Spring Boot系列(四) Spring Boot 之验证

    这节没有高深的东西, 但有一些学习思路值得借鉴. JSR 303 (Bean Validation) Maven依赖 <dependency> <groupId>org.spr ...

  3. springSecurity5 重定向登录页面后 报错:尝试清除 Cookie.net::ERR_TOO_MANY_REDIRECTS status:200

    springSecurity5 使用: http.formLogin().loginPage("/login");报错如下图: springsucurity5 中 需要给 自己定义 ...

  4. 028 (H5*) 商城实战

    目录: 正文: 1:创建项目 介绍 ESlintESLint 是一个ECMAScript/JavaScript 语法规则和代码风格的检查工具,它的目标是保证代码的一致性和避免错误. utit test ...

  5. Struts2的核心配置文件

    Struts2的详细配置: 配置的是struts2的核心配置文件:,在struts2的核心配置文件中主要有三个标签需要进行配置:package,action,result. 1. 配置package标 ...

  6. windows 使用nginx

    windows 安装nginx 进入此地址进行下载 http://nginx.org/en/download.html 解压到相关目录 启动 start nginx 关闭 nginx -s stop ...

  7. [常用类]Math、Random、System、BigInteger、BigDecimal

    Math类中的成员全是静态成员,构造方法是 私有的,以避免被创建对象 常用方法: int abs() double ceil() //向上取整 double floor() //向下取整 int ma ...

  8. Linux安装Python3以及虚拟环境

    python3的linux环境编译安装 1.linux下安装软件的方式 选则yum工具,方便,自行解决软件之间的依赖关系,自动下载且安装 1.配置yum源 可以选择阿里云源,清华源等 配置第一个仓库, ...

  9. 小白学Python(11)——pyecharts,绘制饼图 Pie

    Pie-基本示例 from example.commons import Faker from pyecharts import options as opts from pyecharts.char ...

  10. python学习笔记(9):容器

    一.容器 0.判断所有的容器是否为空,用if not xxx(容器名):来进行判断 1.list 列表 序列是Python中最基本的数据结构.序列中的每个元素都分配一个数字 - 它的位置,或索引,第一 ...