/// <summary> /// 设置终结点参数 /// </summary> /// <param name="uri"></param> /// <param name="binding"></param> /// <param name="key"></param> private void SetBindingParam(Uri uri, BindingType binding, string key) { if (binding == BindingType.netTcpBinding && !bindingconfig.NetTcpBinding.ContainsKey(key)) { NetTcpBindingElement ele = new NetTcpBindingElement(); ele.OpenTimeout = TimeSpan.FromMinutes(5); ele.CloseTimeout = TimeSpan.FromMinutes(5); ele.SendTimeout = TimeSpan.FromMinutes(5); ele.ReceiveTimeout = TimeSpan.FromMinutes(5); ele.MaxReceivedMessageSize = 2147483647; ele.MaxBufferSize = 2147483647; ele.MaxBufferPoolSize = 2147483647; ele.PortSharingEnabled = _PortSharingEnabled; ele.ReaderQuotas.MaxArrayLength = 2147483647; ele.ReaderQuotas.MaxStringContentLength = 2147483647; ele.ReaderQuotas.MaxDepth = 2147483647; ele.ReaderQuotas.MaxBytesPerRead = 2147483647; ele.ReaderQuotas.MaxNameTableCharCount = 2147483647; ele.Security.Mode = SecurityMode.None; ele.Name = key; bindingconfig.NetTcpBinding.Bindings.Add(ele); } else if (binding == BindingType.WSDualHttpBinding && !bindingconfig.WSDualHttpBinding.ContainsKey(key)) { WSDualHttpBindingElement ele = new WSDualHttpBindingElement(); ele.OpenTimeout = TimeSpan.FromMinutes(5); ele.CloseTimeout = TimeSpan.FromMinutes(5); ele.SendTimeout = TimeSpan.FromMinutes(5); ele.ReceiveTimeout = TimeSpan.FromMinutes(5); ele.MaxReceivedMessageSize = 2147483647; //ele.ClientBaseAddress = uri; ele.MaxBufferPoolSize = 2147483647; ele.ReaderQuotas.MaxArrayLength = 2147483647; ele.ReaderQuotas.MaxStringContentLength = 2147483647; ele.ReaderQuotas.MaxDepth = 2147483647; ele.ReaderQuotas.MaxBytesPerRead = 2147483647; ele.ReaderQuotas.MaxNameTableCharCount = 2147483647; ele.Security.Mode = WSDualHttpSecurityMode.None; ele.Name = key; ele.UseDefaultWebProxy = false; if (ClientBaseAddress != null) ele.ClientBaseAddress = ClientBaseAddress; bindingconfig.WSDualHttpBinding.Bindings.Add(ele); } else if (binding == BindingType.BasicHttpBinding && !bindingconfig.BasicHttpBinding.ContainsKey(key)) { BasicHttpBindingElement ele = new BasicHttpBindingElement(); ele.OpenTimeout = TimeSpan.FromMinutes(5); ele.CloseTimeout = TimeSpan.FromMinutes(5); ele.SendTimeout = TimeSpan.FromMinutes(5); ele.ReceiveTimeout = TimeSpan.FromMinutes(5); ele.MaxReceivedMessageSize = 2147483647; ele.MaxBufferSize = 2147483647; ele.MaxBufferPoolSize = 2147483647; ele.ReaderQuotas.MaxArrayLength = 2147483647; ele.ReaderQuotas.MaxStringContentLength = 2147483647; ele.ReaderQuotas.MaxDepth = 2147483647; ele.ReaderQuotas.MaxBytesPerRead = 2147483647; ele.ReaderQuotas.MaxNameTableCharCount = 2147483647; ele.Security.Mode = BasicHttpSecurityMode.None; ele.Name = key; ele.UseDefaultWebProxy = false; bindingconfig.BasicHttpBinding.Bindings.Add(ele); } else if (binding == BindingType.WSHttpBinding && !bindingconfig.WSHttpBinding.ContainsKey(key)) { WSHttpBindingElement ele = new WSHttpBindingElement(); ele.OpenTimeout = TimeSpan.FromMinutes(5); ele.CloseTimeout = TimeSpan.FromMinutes(5); ele.SendTimeout = TimeSpan.FromMinutes(5); ele.ReceiveTimeout = TimeSpan.FromMinutes(5); ele.MaxReceivedMessageSize = 2147483647; //ele.MaxBufferSize = 2147483647; ele.MaxBufferPoolSize = 2147483647; ele.ReaderQuotas.MaxArrayLength = 2147483647; ele.ReaderQuotas.MaxStringContentLength = 2147483647; ele.ReaderQuotas.MaxDepth = 2147483647; ele.ReaderQuotas.MaxBytesPerRead = 2147483647; ele.ReaderQuotas.MaxNameTableCharCount = 2147483647; ele.Security.Mode = SecurityMode.None; ele.Name = key; ele.UseDefaultWebProxy = false; bindingconfig.WSHttpBinding.Bindings.Add(ele); } }
void EnsureWSProfileBindingAdded(Configuration config) { ServiceModelSectionGroup sg = ServiceModelSectionGroup.GetSectionGroup(config); if (!sg.Bindings.WSHttpBinding.Bindings.ContainsKey(this.DefaultBindingName)) { WSHttpBindingElement bindingConfig = new WSHttpBindingElement(this.DefaultBindingName); bindingConfig.ReliableSession.Enabled = true; sg.Bindings.WSHttpBinding.Bindings.Add(bindingConfig); } if (!sg.Bindings.WSHttpBinding.Bindings.ContainsKey(this.DefaultTransactionalBindingName)) { WSHttpBindingElement bindingConfig = new WSHttpBindingElement(this.DefaultTransactionalBindingName); bindingConfig.ReliableSession.Enabled = true; bindingConfig.TransactionFlow = true; sg.Bindings.WSHttpBinding.Bindings.Add(bindingConfig); } }