WCF开发框架 - NetTcpBinding配置web.config与C#代码配置


  WCF开发框架 - NetTcpBinding配置web.config与C#代码配置
WCF开发框架 - NetTcpBinding配置web.config与C#代码配置



NetTcpBinding绑定,web.config配置



XML Code:

<bindings>
<netTcpBinding>
<binding name="NetTcpBinding" closeTimeout="00:01:00"
openTimeout
="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow
="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode
="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize
="1048576" maxConnections="10" maxReceivedMessageSize="1048576">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength
="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled
="false" />
<security mode="Transport">
<transport clientCredentialType="Transport" protectionLevel="None">
</transport>
<message clientCredentialType="None" />
</security>
</binding>

</netTcpBinding>
</bindings>


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





创建NetTcpBinding协议绑定


C# Code:


/// <summary>
/// 创建NetTcpBinding协议绑定
/// </summary>
/// <param name="https"></param>
/// <returns></returns>
public static NetTcpBinding CreateNetTcpBinding(bool https = false)
{
  NetTcpBinding ws
= new NetTcpBinding();
  
  ws.Name
= "NetTcpBinding";
  
  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.HostNameComparisonMode
= HostNameComparisonMode.StrongWildcard;
  ws.PortSharingEnabled
= false;//获取或设置一个值,该值指示是否为采用此绑定配置的连接启用 TCP 端口共享。
  
  
//ws.MaxConnections = 256;//如果修改maxConnections的值,服务会导致不正常,会报端口已经被占用
  
//ws.ListenBacklog = 10;
  

  ws.TransferMode
= TransferMode.Buffered;
  ws.TransactionProtocol
= TransactionProtocol.OleTransactions;
  ws.TransactionFlow
= false;
  
  ws.ReliableSession.Ordered
= true;
  ws.ReliableSession.InactivityTimeout
= new TimeSpan(0, 10, 0);
  
  
//security节点配置 - HTTPS 协议配置
  
if (https)
  {
    ws.Security.Mode
= SecurityMode.Transport;
    ws.Security.Transport.ClientCredentialType
= TcpClientCredentialType.None;
    ws.Security.Transport.ProtectionLevel
= System.Net.Security.ProtectionLevel.None;
    
  }
  
else
  {
    
//security节点配置 - HTTP协议配置
    
ws.Security.Mode = SecurityMode.None;
    ws.Security.Transport.ClientCredentialType
= TcpClientCredentialType.None;
    ws.Security.Transport.ProtectionLevel
= System.Net.Security.ProtectionLevel.None;
  }
  
  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框架网
上一篇:VS2017发布ASP.NET网站应用程序提示:发布遇到错误由于构建错误,发布失败
下一篇:WCF开发框架 - BasicHttpBinding绑定的web.config与C#代码配置(支持https协议)
评论列表

发表评论

评论内容
昵称:
关联文章

WCF开发框架 - NetTcpBinding配置web.configC#代码配置
WCF开发框架 - BasicHttpBinding绑定的web.configC#代码配置(支持https协议)
WCF快速开发框架 - IIS承载WCF net.tcp协议NetTcpBinding配置详解
WCF开发框架之WSHttpBinding参数配置(C#代码配置+App.Config两种方案)
WCF App.Config 配置参数详解:OpenTimeout, CloseTimeout, SendTimeout, ReceiveTimeout
WCF快速开发框架 - IIS承载WCF http协议BasicTcpBinding配置详解
WCF快速开发框架 - IIS承载WCF服务wsHttpBindings配置详解(HTTP协议)
CSFramework.WebApi后端框架 - 系统配置 - app.config
WCFWeb Service的区别关系
Winform企业级WCF快速开发框架平台(C/S架构+WCF+DevExpress+SQL多数据库)
C/S开发框架代码生成器工具增加DevExpress版本配置
Web服务(Web Service)
C#源代码安全缺陷提高源代码质量解决方案-WCF服务配置安全
【原创】WCF开发框架 - 采用wsHttpBinding及basicHttpBinding连接https协议的WCF服务
C/S开发框架是否支持网页Web开发
开发平台WCF架构(Web服务)使用压缩数据双向通信测试报告
WCF开发环境客户端调试服务端跟踪代码不能命中断点解决方案
C/S服务器框架WCF框架 - C/S框架
基于WCF通信的C/S系统快速开发框架的部分架构设计
代码生成器 CodeGenerator - 系统参数配置

热门标签
.NET5 .NET6 .NET7 APP Auth-软件授权注册系统 Axios B/S B/S开发框架 Bug Bug记录 C#加密解密 C#源码 C/S CHATGPT CMS系统 CodeGenerator CSFramework.DB CSFramework.EF CSFrameworkV1学习版 CSFrameworkV2标准版 CSFrameworkV3高级版 CSFrameworkV4企业版 CSFrameworkV5旗舰版 CSFrameworkV6.0 DAL数据访问层 Database datalock DbFramework Demo教学 Demo下载 DevExpress教程 DOM EF框架 Element-UI EntityFramework ERP ES6 Excel FastReport GIT HR IDatabase IIS JavaScript LINQ MES MiniFramework MIS NavBarControl Node.JS NPM OMS ORM PaaS POS Promise API Redis SAP SEO SQL SQLConnector TMS系统 Token令牌 VS2022 VSCode VUE WCF WebApi WebApi NETCore WebApi框架 WEB开发框架 Windows服务 Winform 开发框架 Winform 开发平台 WinFramework Workflow工作流 Workflow流程引擎 版本区别 报表 踩坑日记 操作手册 代码生成器 迭代开发记录 基础资料窗体 架构设计 角色权限 开发sce 开发技巧 开发教程 开发框架 开发平台 开发指南 客户案例 快速搭站系统 快速开发平台 秘钥 密钥 权限设计 软件报价 软件测试报告 软件简介 软件开发框架 软件开发平台 软件开发文档 软件体系架构 软件下载 软著证书 三层架构 设计模式 生成代码 实用小技巧 收钱音箱 数据锁 数据同步 微信小程序 未解决问题 文档下载 喜鹊ERP 喜鹊软件 系统对接 详细设计说明书 行政区域数据库 需求分析 疑难杂症 蝇量级框架 蝇量框架 用户管理 用户开发手册 用户控件 在线支付 纸箱ERP 智能语音收款机 自定义窗体 自定义组件 自动升级程序