WCF开发框架之WSHttpBinding参数配置(C#代码配置+App.Config两种方案)

  WCF开发框架之WSHttpBinding参数配置(C#代码配置+App.Config两种方案)

WCF开发框架之WSHttpBinding参数配置(C#代码配置+App.Config两种方案)



app.config文件WSHttpBinding参数配置


XML Code:

<!--WCF服务客户端配置-->
<system.serviceModel>

<bindings>
<wsHttpBinding>

<binding name="wsHttpBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal
="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize
="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />

<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
</security>

</binding>

</wsHttpBinding>
</bindings>

</system.serviceModel>


//来源:C/S框架网 | www.csframework.com | QQ:23404761


C#代码配置


C# Code:


/// <summary>
/// 设置WSHttpBinding参数配置
/// </summary>
/// <param name="ws"></param>
public static void SetWSHttpBinding(WSHttpBinding ws)
{
  ws.Name
= "wsHttpBinding";
  ws.CloseTimeout
= new TimeSpan(0, 10, 0);
  ws.OpenTimeout
= new TimeSpan(0, 10, 0);
  ws.ReceiveTimeout
= new TimeSpan(0, 10, 0);
  ws.SendTimeout
= new TimeSpan(0, 10, 0);
  
  ws.MaxBufferPoolSize
= 2147483647;//从通道接收消息的最大缓存数量
  
ws.MaxReceivedMessageSize = 2147483647;//最大接收的消息大小
  

  ws.BypassProxyOnLocal
= false;
  ws.TransactionFlow
= false;
  ws.HostNameComparisonMode
= HostNameComparisonMode.StrongWildcard;
  
  ws.MessageEncoding
= WSMessageEncoding.Text;
  ws.TextEncoding
= Encoding.UTF8;
  ws.UseDefaultWebProxy
= true;
  ws.AllowCookies
= false;
  
  
//readerQuotas节点配置
  
System.Xml.XmlDictionaryReaderQuotas rq = ws.ReaderQuotas;
  rq.MaxArrayLength
= 2147483647;//最大数组长度
  
rq.MaxBytesPerRead = 6553600;//最大每次读取长度
  
rq.MaxDepth = 6553600;// 最大节点深度
  
rq.MaxNameTableCharCount = 6553600;//最大NameTableChar的数量
  
rq.MaxStringContentLength = 2147483647;// 最大内容长度
  
  
//reliableSession节点配置
  
ws.ReliableSession.Enabled = false;
  ws.ReliableSession.Ordered
= true;
  ws.ReliableSession.InactivityTimeout
= new TimeSpan(0, 10, 0);
  
  
//security节点配置
  
ws.Security.Mode = SecurityMode.None;
  ws.Security.Transport.ClientCredentialType
= HttpClientCredentialType.None;
  ws.Security.Transport.ProxyCredentialType
= HttpProxyCredentialType.None;
  ws.Security.Message.ClientCredentialType
= MessageCredentialType.None;
  ws.Security.Message.EstablishSecurityContext
= false;
  ws.Security.Message.NegotiateServiceCredential
= false;
}

//来源:C/S框架网 | www.csframework.com | QQ:23404761





C/S框架网|原创精神.创造价值.打造精品


扫一扫加作者微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务
版权声明:本文为CSFramework文库发布内容,转载请附上原文出处连接
C/S框架网
发表评论

评论内容
昵称:
关联文章

WCF开发框架WSHttpBinding参数配置(C#代码配置+App.Config方案)
WCF App.Config 配置参数详解:OpenTimeout, CloseTimeout, SendTimeout, ReceiveTimeout
WCF快速开发框架 - IIS承载WCF服务wsHttpBindings配置详解(HTTP协议)
WCF开发框架 - NetTcpBinding配置web.configC#代码配置
WCF开发框架 - BasicHttpBinding绑定的web.configC#代码配置(支持https协议)
【原创】WCF开发框架 - 采用wsHttpBinding及basicHttpBinding连接https协议的WCF服务
系统配置 - app.config
WCF开发环境客户端调试服务端跟踪代码不能命中断点解决方案
Winform软件快速开发平台 - 关于数据权限,表格列权限控制解决方案
WCF快速开发框架 - IIS承载WCF http协议BasicTcpBinding配置详解
WCF快速开发框架 - IIS承载WCF net.tcp协议NetTcpBinding配置详解
C#源代码安全缺陷与提高源代码质量解决方案-WCF服务配置安全
Winform企业级WCF快速开发框架平台(C/S架构+WCF+DevExpress+SQL多数据库)
C#开发实例-数据字典作为参考数据在表格中显示的方案
2.4系统参数配置
Winform开发框架测试程序测试环境配置|C/S框架
用户请求类型 (User Request)参数模型
WCF开发框架ICommunicationObject 对象详解
Winform快速开发框架存储图片资源解决方案|C/S框架
WCF开发框架-客户端采用Certificate认证模式调用基于HTTPS协议的WCF接口