Пример #1
0
		public void DefaultTextEncoding ()
		{
			var b1 = new BasicHttpBinding ();
			var b2 = new BasicHttpBinding ();
			Assert.AreEqual (b1.TextEncoding, b2.TextEncoding, "#1");
			
			var element = new BasicHttpBindingElement ();
			Assert.AreEqual (element.TextEncoding, b1.TextEncoding, "#2");
		}
Пример #2
0
 private void CheckRuleForBasicBinding(BasicHttpBindingElement basicHttpBinding)
 {
     if (basicHttpBinding != null &&
         (basicHttpBinding.Security.Mode == BasicHttpSecurityMode.None ||
          (basicHttpBinding.Security.Mode == BasicHttpSecurityMode.Message &&
           basicHttpBinding.Security.Message.ClientCredentialType == BasicHttpMessageCredentialType.UserName)
          )
         )
     {
         AddProblem(basicHttpBinding.Name);
     }
 }
        public void AddStandardBindingTest()
        {
            BasicHttpBindingElement element = new BasicHttpBindingElement("newBasicBinding");
            ServiceModelConfigurationManager manager = LoadManager();
            manager.AddStandardBinding<BasicHttpBinding, BasicHttpBindingElement>(element);

            BasicHttpBindingElement addedElement = manager.GetStandardBinding<BasicHttpBinding, BasicHttpBindingElement>(element.Name);

            Assert.AreEqual(element.Name, addedElement.Name);
        }
        public void CanGetDefaultStandardBindingWithNullBindingName()
        {
            BasicHttpBindingElement defaultElement = new BasicHttpBindingElement("NewBinding");
            BasicHttpBindingElement element = LoadManager().GetStandardBinding<BasicHttpBinding, BasicHttpBindingElement>(null);

            Assert.IsTrue(string.IsNullOrEmpty(element.Name));
            Assert.AreEqual(defaultElement.Security, element.Security);
        }
Пример #5
0
        internal static void CreateConfig(Binding binding, string filename)
        {
            if (false && File.Exists (filename))
                File.Delete (filename);

            var element = new BasicHttpBindingElement ("Test");
            foreach (PropertyInformation prop in element.ElementInformation.Properties) {
                Console.WriteLine ("PROP: {0} {1}", prop.Name, prop.IsRequired);
            }

            var fileMap = new ExeConfigurationFileMap ();
            fileMap.ExeConfigFilename = filename;
            var config = ConfigurationManager.OpenMappedExeConfiguration (
                fileMap, ConfigurationUserLevel.None);

            Console.WriteLine ("CREATE CONFIG: {0}", binding.Name);

            var generator = new ServiceContractGenerator (config);

            string sectionName, configName;
            generator.GenerateBinding (binding, out sectionName, out configName);

            Console.WriteLine ("CONFIG: {0} {1} {2}", binding, sectionName, configName);

            config.Save (ConfigurationSaveMode.Minimal);
            Console.WriteLine ("CONFIG: {0}", config.FilePath);

            NormalizeConfig (filename);
            Dump (config.FilePath);
        }
Пример #6
0
 /// <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);
     }
 }