创建WCF的客户端
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
How to: Use a Windows Communication Foundation Client
创建WCF的客户端的更多相关文章
- WCF开发实战系列五:创建WCF客户端程序
WCF开发实战系列五:创建WCF客户端程序 (原创:灰灰虫的家http://hi.baidu.com/grayworm) 在前面的三篇文章中我们分别介绍了WCF服务的三种载体:IIS.Self-Hos ...
- WCF入门教程(二)如何创建WCF服务
WCF入门教程(二)从零做起-创建WCF服务 通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK默认创建的样本 1.创建WCF服务库 2.看其生成结构 1)IService1.cs(协议) ...
- 重温WCF之WCF传输安全(十三)(4)基于SSL的WCF对客户端采用证书验证(转)
转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/20/2695397.html 前一篇我们演示了基于SSL的WCF 对客户端进行用户名和密码方式的 ...
- Wcf for wp8 创建wcf服务 连接wp8模拟器并显示来自wcf服务的接口信息 (一)
下载: vs2012 pro for wp8 iis express http://download.microsoft.com/download/B/2/8/B2801FEE-9A60-4AFA-8 ...
- WCF入门教程(二)从零做起-创建WCF服务
通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK默认创建的样本 1.创建WCF服务库 2.看其生成结构 1)IService1.cs(协议) 定义了协议,具体什么操作,操作的参数和返回值 ...
- SharePoint 2013创建WCF REST Service
SharePoint 2013为开发者提供了丰富的REST API,方便了我们在客户端操作List中的数据.当然我们也可以在SharePoint 2013中创建自定义的REST Service,比如通 ...
- WCF 创建WCF
一.概述 Windows Communication Foundation(WCF)是由微软发展的一组数据通信的应用程序开发接口,可以翻译为Windows通讯接口,它是.NET框架的一部分.由 .NE ...
- 快速创建WCF服务和svcutil.exe工具使用
先简单的创建WCF服务: 系统会自动加上IService1接口 和 Service1 实现类 分别在IService1 和Service1 加上2段代码. [ServiceContract] publ ...
- WebService及WCF获取客户端IP,端口
wcf获取客户端IP,端口 var context = OperationContext.Current; var properties = context.IncomingMessageProper ...
随机推荐
- 学习C++ Primer 的个人理解(九)
这一章介绍顺序容器,在之前的第三章中,了解到的vector就属于顺序容器的一种. 一个容器就是一些特定类型对象的集合. 除了vector,还有哪些顺序容器? vector: 大小可变,随机访问的速度很 ...
- ifstream:incomplete type is not allowed
IntelliSense: incomplete type is not allowed ifstream inputFile; Need to add this: #include <fstr ...
- C#方法解析
“方法”是包含一系列语句的代码块. 程序通过“调用”方法并指定所需的任何方法参数来执行语句. 在 C# 中,每个执行指令 都是在方法的上下文中执行的. 最近在写一个反射调用时,需要通过反射来调用方法. ...
- Html盒子模型学习总结
Html的盒子模型 1.总的来说Html元素可以分为两类:即块状元素和行内元素. 2.块状元素(Block)类型的元素可以设置Width和Height值属性,而行内(Inline)类型无效. 3.浏览 ...
- 简单的NHibernate学习笔记
NHibernate是.NET平台下的ORM框架,与ADO.NET一样实现项目中数据库与项目系统的交互. .首先要用NHibernate框架就要有第三方的dll库来作为支持,附上百度云下载地址:(链接 ...
- Yii Query Builder insert()、update()、delete()使用
Yii自带的query builder还是很好用的,省去了拼sql的过程,今天在写一个语句的时候遇到这样一个问题 $connection = Yii::app()->db; $command = ...
- “0x5003eaed” 指令引用的“0x00000000”内存。该内存不能为“read”
一.问题描述与原因分析 1.问题描述 使用VC6.0,在工具栏点击“打开文件”或者“添加文件到项目”的图标时,提示如题的错误. 2.原因分析 微软的VC6.0与office2007冲突问题. 二.解决 ...
- POJ 3254 压缩状态DP
题意:一个矩形网格,可以填0或1, 但有些位置什么数都不能填,要求相邻两个不同时为1,有多少种填法.矩形大小最大 12*12. 压缩状态DP大多有一个可行的state的范围,先求出这个state范围, ...
- Call Azure Queue get "The remote server returned an error: (400) Bad Request."
这几天开始研究Windows Azure, 在使用Azure Queue 的时候,CreateInfNotExists 总是抛出异常 "The remote server returned ...
- SmartGit初步使用
在Git如日中天的今天,我也不免俗的想用Git将业余时间写的代码管理一下. 什么是Git这里不多说,具体见廖雪峰的Git教程,ProGit等详细教程. 我们这里直接上手. 一.下载Git客户端 1.G ...