C#编码直接调用WCF服务时协议参数设置
C#编码直接调用WCF服务时协议参数设置
C# Code:
private WSHttpBinding GetWSHttpBinding() { //wsHttpBinding WSHttpBinding ws = new WSHttpBinding(SecurityMode.None); ws.CloseTimeout = new TimeSpan(0, 1, 0); ws.OpenTimeout = new TimeSpan(0, 1, 0); ws.ReceiveTimeout = new TimeSpan(0, 20, 0); ws.SendTimeout = new TimeSpan(0, 1, 0); ws.BypassProxyOnLocal = false; ws.TransactionFlow = false; ws.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; ws.MaxBufferPoolSize = 524288; //获取或设置可为缓冲区管理器分配的最大内存量 ws.MaxReceivedMessageSize = 2147483647;//获取或设置可由绑定处理的消息的最大大小 ws.MessageEncoding = WSMessageEncoding.Text; ws.TextEncoding = Encoding.UTF8; ws.UseDefaultWebProxy = true; ws.AllowCookies = false; ws.ReaderQuotas.MaxDepth = 6553600;//Gets and sets the maximum nested node depth ws.ReaderQuotas.MaxStringContentLength = 2147483647;//Gets and sets the maximum string length returned by the reader ws.ReaderQuotas.MaxArrayLength = 6553600;//Gets and sets the maximum allowed array length ws.ReaderQuotas.MaxBytesPerRead = 6553600;// Gets and sets the maximum allowed bytes returned for each read ws.ReaderQuotas.MaxNameTableCharCount = 6553600;//Gets and sets the maximum characters allowed in a table name ws.ReliableSession.Ordered = true; ws.ReliableSession.InactivityTimeout = new TimeSpan(0, 20, 0); ws.ReliableSession.Enabled = true; ws.Security.Mode = SecurityMode.None; ws.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; ws.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; ws.Security.Transport.Realm = ""; ws.Security.Message.ClientCredentialType = MessageCredentialType.Windows; ws.Security.Message.NegotiateServiceCredential = true; ws.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default; ws.Security.Message.EstablishSecurityContext = false; return ws; } //来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加作者微信
参考文档:
连接WCF服务错误:调用方未由服务进行身份验证,无法满足对安全令牌的请求 C# JsonSettings/JsonSerializerSettings参数设置类 WCF开发框架之WSHttpBinding参数配置(C#代码配置+App.Config两种方案) WCF开发框架 - BasicHttpBinding绑定的web.config与C#代码配置(支持https协议) 提供的URI方案http无效,应为https,参数名via - WCF服务采用HTTPS协议 WCF快速开发框架 - IIS承载WCF服务wsHttpBindings配置详解(HTTP协议) 【原创】WCF开发框架 - 采用wsHttpBinding及basicHttpBinding连接https协议的WCF服务 vs使用添加服务引用方式连接HTTPS协议的WCF服务 vs使用透明代理工厂方式调用HTTPS协议的WCF服务 WCF开发框架-客户端采用BASIC身份认证调用HTTPS协议WCF接口 WCF开发框架-客户端采用Windows身份认证调用HTTPS协议WCF接口 调用WCF服务System.ServiceModel.ServiceActivationException:"无法激活请求的服务" WCF开发框架-客户端采用Certificate认证模式调用基于HTTPS协议的WCF接口 WCF:SecurityNegotiationException 调用方未由服务进行身份验证 C#源代码安全缺陷与提高源代码质量解决方案-WCF服务配置安全
其它资料:
什么是C/S结构? | C/S框架核心组成部分 | C/S框架-WebService部署图 | C/S框架-权限管理 | C/S结构系统框架 - 5.1旗舰版介绍 | C/S结构系统框架 - 功能介绍 | C/S结构系统框架 - 产品列表 | C/S结构系统框架 - 应用展示(图) | 三层体系架构详解 | C/S架构轻量级快速开发框架 | C/S框架网客户案例 | WebApi快速开发框架 | C/S框架代码生成器 | 用户授权注册软件系统 | 版本自动升级软件 | 数据库底层应用框架 | CSFramework.CMS内容管理系统 | |