How to: Create a Windows Communication Foundation Client
How to: Create a Windows Communication Foundation Client
To create a Windows Communication Foundation client
-
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.
-
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.
-
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.
-
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
相关文章
- Windows下Nginx的启动、停止等命令&Nginx 配置多域名&windows下设置Nginx开机自动启动
- Windows下解决github push failed (remote: Permission to userA/XXXX.git denied to userB.) 上传gitHub失败报错
- PC-windows系统中exe调用dll搜索路径顺序
- 访问windows共享无法分配内存问题解决
- Windows魔法堂:解决“由于启动计算机时出现页面文件配置问题.......”
- Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
- 转 windows查看端口占用命令
- python卸载或者安装时提示There is a problem with this Windows Installer package.A program required for this install to complete could not be run. Contact your support personnel or package vendor
- Windows下安装与配置Nginx web服务器
- 用EasyClient开源项目采集Windows摄像头/麦克风的音视频进行RTSP直播
- Windows下pip安装包报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat
- Flink(41):Flink之TableAPI和FlinkSQL的窗口(Windows)
- MFC Windows 程序设计[308]之界面的全屏处理(附源码)
- MFC Windows 程序设计[233]之CPP十六进制编辑器(附源码)
- MFC Windows 程序设计[207]之频谱奥秘图(附源码)
- MFC Windows 程序设计[四]之Hello, MFC
- OCR - 微软windows 11系统自带的Windows OCR功能初体验
- windows杀死指定端口号
- How to debug .NET Core RC2 app with Visual Studio Code on Windows?
- kaptcha验证码在windows下正常,在linux下无法显示
- Windows环境下,如何在Docker里运行SAP UI5应用
- 【Codeforces 231C】To Add or Not to Add
- windows 环境下使用 Node.js 访问 SAP OData 遇到 unable to get local issuer certificate
- You currently don‘t have access to this membership resource. To resolve this issue, agree to the lat
- 成功解决Docker Desktop requires Windows 10 Pro or Enterprise version 15063 to run.
- Windows之Chocolatey:windows下的apt-get即Chocolatey简介、安装、使用方法之详细攻略
- 基于QT 的C++ Windows定时关机程序
- windows server 2008 安装Microsoft ActiveSync 6.1提示缺少一个Windows Mobile设备中心所须要的Windows组件
- How_to_setup_Qt_and_openCV_on_Windows
- 【Android Gradle 插件】自定义 Gradle 插件模块 ③ ( Gradle 插件模块发布配置 | Windows 本地 Maven 仓库地址 | 将插件上传到本地 Maven 仓库 )
- 【错误记录】Windows 控制台程序编译报错 ( WINDOWS.H already included. MFC apps must not #include <Windows.h> )
- Windows下使用Redis(一)安装使用
- android windows 上JNI编程
- PAT 1033. To Fill or Not to Fill (贪婪)
- 64位Windows操作系统中的注冊表
- C# Windows目录排序
- C# 编写Windows Service(windows服务程序)
- Proxychains.exe - Proxychains for Windows ——通过给动态链接的程序注入一个 DLL,对 Ws2_32.dll 的 Winsock 函数挂钩子的方式来将应用程序的连接重定向到 SOCKS5 代理
- windows server2019 AD域控制器组策略 打开组策略提示域控制器不存在