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

最新文章

  1. scrapy 知乎用户信息爬虫
  2. 用vuejs写了一个酷狗的webApp
  3. OpenGL的glTexCoord2f纹理坐标配置
  4. 按Right-BICEP的测试用例
  5. 通过profile 用maven命令打不同配置的变量包
  6. Yii2框架数据库增删改查小结
  7. mysql my.ini 详解
  8. javascript——集合类
  9. 读懂Swift 2.0中字符串设计思路的改变
  10. Dynamics CRM2013/2015 禁止欢迎屏幕(Disable the Welcome Screen)
  11. Android属性动画 nineoldandroids
  12. EventBus 最简易的使用方式
  13. 树莓派B+使用入门&RPI库安装&wringPi库安装
  14. CentOS7 分布式安装 Hadoop 2.8
  15. JavaScript BOM和DOM
  16. python中执行shell命令的几个方法小结
  17. JavaSE回顾及巩固的自学之路(三)——————所有语言的都存在的基本运算
  18. Junit4测试用例
  19. Code::Blocks代码自动提示设置及常用快捷键
  20. python的开发环境配置-Eclipse-PyDev插件安装

热门文章

  1. 【Unity Shader】---UnityShader 提供的CG/HLSL语义
  2. failed to create process ,pip报错问题
  3. 应用安全 - 软件漏洞 - Jira漏洞汇总
  4. SpringMvc+Mybatis开发调用存储过程
  5. python 正确复制list,克隆list 的各种方案
  6. Django - Xadmin (三) 分页、搜索和批量操作
  7. [环境搭建]-Web Api搭建到IIS服务器后PUT请求返回HTTP Error 405.0 - Method Not Allowed 解决方法 转摘:http://blog.csdn.net/qiujuer/article/details/23827531
  8. js中对象的属性名和属性值
  9. HTTP 几种常用的认证机制
  10. nodepad++如何多行同时编辑