WCF开发框架 - BasicHttpBinding绑定的web.config与C#代码配置(支持https协议)

  WCF开发框架 - BasicHttpBinding绑定的web.config与C#代码配置(支持https协议)
WCF开发框架 - BasicHttpBinding绑定的web.config与C#代码配置(支持https协议)



BasicHttpBinding绑定的web.config配置



XML Code:

<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies
="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize
="1048576" maxBufferPoolSize="524288" maxReceivedMessageSize="1048576"
messageEncoding
="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>

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




BasicHttpBinding绑定的C# 代码:


C# Code:


/// <summary>
/// 创建BasicHttpBinding协议绑定
/// </summary>
/// <param name="ws"></param>
public static BasicHttpBinding CreateBasicHttpBinding(bool https = false)
{
  BasicHttpBinding ws
= new BasicHttpBinding();
  
  ws.Name
= "BasicHttpBinding";
  ws.MaxReceivedMessageSize
= 2147483647;//最大接收的消息大小
  
ws.MaxBufferSize = 2147483647;// 从通道接收消息的缓存大小
  
ws.MaxBufferPoolSize = 2147483647;//从通道接收消息的最大缓存数量
  
ws.CloseTimeout = new TimeSpan(0, 10, 0);
  ws.OpenTimeout
= new TimeSpan(0, 10, 0);
  ws.SendTimeout
= new TimeSpan(0, 10, 0);
  ws.ReceiveTimeout
= new TimeSpan(0, 10, 0);
  
  ws.AllowCookies
= false;
  ws.BypassProxyOnLocal
= false;
  ws.HostNameComparisonMode
= HostNameComparisonMode.StrongWildcard;
  ws.MessageEncoding
= WSMessageEncoding.Text;
  ws.TextEncoding
= Encoding.UTF8;
  ws.TransferMode
= TransferMode.Buffered;
  ws.UseDefaultWebProxy
= true;
  
  
//security节点配置 - HTTPS 协议配置
  
if (https)
  {
    ws.Security.Mode
= BasicHttpSecurityMode.Transport;
    ws.Security.Transport.ClientCredentialType
= HttpClientCredentialType.None;
    ws.Security.Transport.ProxyCredentialType
= HttpProxyCredentialType.None;
    ws.Security.Transport.Realm
= "";
  }
  
else
  {
    
//security节点配置 - HTTP协议配置
    
ws.Security.Mode = BasicHttpSecurityMode.None;
    ws.Security.Transport.ClientCredentialType
= HttpClientCredentialType.None;
    ws.Security.Transport.ProxyCredentialType
= HttpProxyCredentialType.None;
    ws.Security.Transport.Realm
= "";
  }
  
  System.Xml.XmlDictionaryReaderQuotas rq
= ws.ReaderQuotas;
  rq.MaxArrayLength
= 2147483647;//最大数组长度
  
rq.MaxBytesPerRead = 6553600;//最大每次读取长度
  
rq.MaxDepth = 6553600;// 最大节点深度
  
rq.MaxNameTableCharCount = 6553600;//最大NameTableChar的数量
  
rq.MaxStringContentLength = 2147483647;// 最大内容长度
  

  
return ws;
}

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





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


扫一扫加作者微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
C/S框架网
上一篇:WCF开发框架 - NetTcpBinding配置web.config与C#代码配置
下一篇:开发框架旗舰版:数据库日志DBLog类实现ILogUserOperate接口设计
评论列表

发表评论

评论内容
昵称:
关联文章

WCF开发框架 - BasicHttpBindingweb.configC#代码配置支持https协议
【原创】WCF开发框架 - 采用wsHttpBinding及basicHttpBinding连接https协议WCF服务
WCF开发框架 - NetTcpBinding配置web.configC#代码配置
WCF快速开发框架 - IIS承载WCF http协议BasicTcpBinding配置详解
WCF快速开发框架 - IIS承载WCF服务wsHttpBindings配置详解(HTTP协议)
WCF开发框架-客户端采用Certificate认证模式调用基于HTTPS协议WCF接口
WCF开发框架-客户端采用Windows身份认证调用HTTPS协议WCF接口
WCF开发框架-客户端采用BASIC身份认证调用HTTPS协议WCF接口
WCF快速开发框架 - IIS承载WCF net.tcp协议NetTcpBinding配置详解
找不到具有 MetadataExchangeHttpBinding 终结点方案 http 匹配基址。注册基址方案是 [https]
C#.NET IP端口SSL证书支持HTTPS协议(用于Win服务自承载WebApi服务器) - C/S框架网原创
WCF开发框架之WSHttpBinding参数配置(C#代码配置+App.Config两种方案)
WCF开发框架默认连接:HTTP协议+Message安全模式+Windows客户端认证
WCF顶级安全:HTTPS协议SSL证书+Windows认证+TransportWithMessageCredential安全模式
WCFWeb Service区别关系
WCF App.Config 配置参数详解:OpenTimeout, CloseTimeout, SendTimeout, ReceiveTimeout
Web服务(Web Service)
提供URI方案http无效,应为https,参数名via - WCF服务采用HTTPS协议
vs使用添加服务引用方式连接HTTPS协议WCF服务
vs使用透明代理工厂方式调用HTTPS协议WCF服务