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. python基础-4 函数参数引用、lambda 匿名函数、内置函数、处理文件

    上节课总结 1.三元运算 name=“name1”if 条件 else “name2” 2.深浅拷贝 数字.字符串 深浅,都一样 2.其他 浅拷贝:只拷贝第一层 深拷贝:不拷贝最后一层 3.set集合 ...

  2. 来自python自学者的小问题

    我想使用python的第三方库,但是我的IDE给我一个错误代码: D:\untitled\venv\Scripts\python.exe "D:/py code/venv/sxsxsxsxs ...

  3. 第一次Java学习总结

    初学Java感觉还是蛮可以的,可是做起题目来还是不能得心应手,自己不懂得太多太多,还是需要不断努力去学啊!下面我就把这些天学到的知识点总结一下: 初学Java,我把目前所学知识点总结如下: 1.jav ...

  4. HTML: 引号不能忽视

    在js中常常生成拼接html,然后放到dom中,但是有些拼接的html标签需要加一些指或者属性,这个时候不能忽略引号 如果data.link_tel有空格,不加单引号导致value的值不完全 str ...

  5. winCE 获取路径信息

    最近在做一个SAP的winCE扫描枪项目,采用C#开发,不过在获取路径是采用了常用的System.IO.Directory.GetCurrentDirectory, 并不能使用:查询后了解到winCE ...

  6. Java学习day2关键字

    java的基本语法(1) 一.关键字 定义:被Java语言赋予特殊含义,用做专门用途的字符串 特点:关键字中的所有字母都为小写 二.标识符 定义:java对各种变量.方法和类等要素命名时所使用的的字符 ...

  7. QT 5.12安装

    QT 5.12为最新的LTS版本,将通过该版本开始QT的学习 1.软件下载 QT5.12下载地址:http://download.qt.io/archive/qt/5.12/ 当前最新版本为5.12. ...

  8. [BZOJ 2989]数列(CDQ 分治+曼哈顿距离与切比雪夫距离的转化)

    [BZOJ 2989]数列(CDQ 分治) 题面 给定一个长度为n的正整数数列a[i]. 定义2个位置的graze值为两者位置差与数值差的和,即graze(x,y)=|x-y|+|a[x]-a[y]| ...

  9. exec 命令

    source source命令即点(.)命令. 在bash下输入man source,找到source命令解释处,可以看到解释”Read and execute commands from filen ...

  10. Version Controlling with Git in Visual Studio Code and Azure DevOps

    Overview Azure DevOps supports two types of version control, Git and Team Foundation Version Control ...