首页 技术 正文
技术 2022年11月18日
0 收藏 981 点赞 4,089 浏览 2076 个字

WCF 基础

ServiceModel 配置元素

WCF 基础

Binding 配置元素:

WCF 基础

客户端Web.config:

<?xml version=”1.0″ encoding=”utf-8″?>

<configuration>

<system.serviceModel>

<!– 描述咋样通信,如:编码、传输协议、安全–>
<bindings>
<basicHttpBinding>
<binding name=”BasicHttpBinding_IUser” closeTimeout=”00:01:00″
openTimeout=”00:01:00″ receiveTimeout=”00:10:00″ sendTimeout=”00:01:00″
allowCookies=”false” bypassProxyOnLocal=”false” hostNameComparisonMode=”StrongWildcard”
maxBufferSize=”65536″ maxBufferPoolSize=”524288″ maxReceivedMessageSize=”65536″
messageEncoding=”Text” textEncoding=”utf-8″ transferMode=”Buffered”
useDefaultWebProxy=”true”>
<readerQuotas maxDepth=”32″ maxStringContentLength=”8192″ maxArrayLength=”16384″
maxBytesPerRead=”4096″ maxNameTableCharCount=”16384″ />
<security mode=”None”>
<transport clientCredentialType=”None” proxyCredentialType=”None”
realm=”” />
<message clientCredentialType=”UserName” algorithmSuite=”Default” />
</security>
</binding>
</basicHttpBinding>
</bindings>

<!–设定匹配端点–>
<client>
<endpoint address=”http://localhost/User.svc” binding=”basicHttpBinding”
bindingConfiguration=”BasicHttpBinding_IUser” contract=”WCFService.IUser”
name=”BasicHttpBinding_IUser” />
</client>
</system.serviceModel>
</configuration>

服务端Web.config代码

<?xml version=”1.0″ encoding=”utf-8″?>
<configuration>

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!– 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 –>
<serviceMetadata httpGetEnabled=”true”/>
<!– 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 –>
<serviceDebug includeExceptionDetailInFaults=”false”/>
</behavior>
</serviceBehaviors>
</behaviors>

<!–匹配所有相同端点的客户端请求:就是A,B,C必须一致–>

<services>
<service name=”WCFService”>
<endpoint address=”http://localhost/User.svc” binding=”basicHttpBinding”
contract=”WCFService.IUser” />
</service>
</services>

<serviceHostingEnvironment multipleSiteBindingsEnabled=”true” />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests=”true”/>
</system.webServer>

</configuration>

//客户端使用

using (ChannelFactory<Ixxx> channelFactory = new ChannelFactory<IEmployees>(endpointConfigName))
{
               
               Ixxx proxy = channelFactory.CreateChannel();
         //dosomething...
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,966
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,487
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,332
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,115
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,748
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,783