WCF框架基础(三)
2012-09-06 13:30
274 查看
1.首先生成配置文件。服务代理,首先添
加服务引用在地址栏里输入上文服务端创建的Uri地址
2.点击确定将生成配置文件
3.使用WCF客户端
至此就可以调用服务端定义的服务
加服务引用在地址栏里输入上文服务端创建的Uri地址
2.点击确定将生成配置文件
<system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" contract="ServiceReference.IService" name="WSHttpBinding_IService"> <identity> <userPrincipalName value="PC-201206011335\Administrator" /> </identity> </endpoint> </client> </system.serviceModel>
3.使用WCF客户端
//创建端终结点 ServiceReference属性在配置文件有终节点处查找 EndpointAddress epAddress = new EndpointAddress("http://localhost:8000/ServiceModelSamples/Service/CalculatorService"); ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(new WSHttpBinding(),epAddress);
至此就可以调用服务端定义的服务
double x=client.Add(3.2, 2.1);
相关文章推荐
- Wcf通讯基础框架方案(四)——横切日志
- Wcf通讯基础框架方案(五)——更新通知
- WCF分布式开发步步为赢(1):WCF分布式框架基础概念
- WCF 基础框架
- WCF框架基础(一)
- WCF框架基础(二)
- Wcf通讯基础框架方案(一)——基本结构
- Wcf通讯基础框架方案(二)——集中配置
- Wcf通讯基础框架方案(三)——客户端
- WCF分布式开发步步为赢(1):WCF分布式框架基础概念
- WCF分布式框架基础概念-1
- WCF分布式开发步步为赢(1):WCF分布式框架基础概念
- Wcf通讯基础框架方案(一)——基本结构
- 【转载】Wcf通讯基础框架方案
- WCF分布式开发步步为赢(1):WCF分布式框架基础概念
- Wcf通讯基础框架方案-解决方案说明以及源代码
- Wcf通讯基础框架方案(六)解决方案说明以及源代码
- WCF分布式开发步步为赢(1):WCF分布式框架基础概念
- 微信公众平台开发教程(三) 基础框架搭建
- Java基础知识之集合框架(一)