Example #1
0
        public override void CopyFrom(ServiceModelExtensionElement from)
        {
            base.CopyFrom(from);
            ServiceDebugElement element = (ServiceDebugElement)from;

            this.HttpHelpPageEnabled               = element.HttpHelpPageEnabled;
            this.HttpHelpPageUrl                   = element.HttpHelpPageUrl;
            this.HttpsHelpPageEnabled              = element.HttpsHelpPageEnabled;
            this.HttpsHelpPageUrl                  = element.HttpsHelpPageUrl;
            this.IncludeExceptionDetailInFaults    = element.IncludeExceptionDetailInFaults;
            this.HttpHelpPageBinding               = element.HttpHelpPageBinding;
            this.HttpHelpPageBindingConfiguration  = element.HttpHelpPageBindingConfiguration;
            this.HttpsHelpPageBinding              = element.HttpsHelpPageBinding;
            this.HttpsHelpPageBindingConfiguration = element.HttpsHelpPageBindingConfiguration;
        }
Example #2
0
        public override void CopyFrom(ServiceModelExtensionElement from)
        {
            base.CopyFrom(from);

            ServiceDebugElement source = (ServiceDebugElement)from;

#pragma warning suppress 56506 //[....]; base.CopyFrom() check for 'from' being null
            this.HttpHelpPageEnabled               = source.HttpHelpPageEnabled;
            this.HttpHelpPageUrl                   = source.HttpHelpPageUrl;
            this.HttpsHelpPageEnabled              = source.HttpsHelpPageEnabled;
            this.HttpsHelpPageUrl                  = source.HttpsHelpPageUrl;
            this.IncludeExceptionDetailInFaults    = source.IncludeExceptionDetailInFaults;
            this.HttpHelpPageBinding               = source.HttpHelpPageBinding;
            this.HttpHelpPageBindingConfiguration  = source.HttpHelpPageBindingConfiguration;
            this.HttpsHelpPageBinding              = source.HttpsHelpPageBinding;
            this.HttpsHelpPageBindingConfiguration = source.HttpsHelpPageBindingConfiguration;
        }
Example #3
0
        protected void EnsureComMetaDataExchangeBehaviorAdded(Configuration config)
        {
            ServiceModelSectionGroup sg = ServiceModelSectionGroup.GetSectionGroup(config);
            if (!sg.Behaviors.ServiceBehaviors.ContainsKey(comServiceBehavior))
            {
                ServiceBehaviorElement behavior = new ServiceBehaviorElement(comServiceBehavior);
                sg.Behaviors.ServiceBehaviors.Add(behavior);
                ServiceMetadataPublishingElement metadataPublishing = new ServiceMetadataPublishingElement();

                if (Tool.Options.Hosting == Hosting.Complus || Tool.Options.Hosting == Hosting.NotSpecified)
                    metadataPublishing.HttpGetEnabled = false;
                else
                    metadataPublishing.HttpGetEnabled = true;
                behavior.Add(metadataPublishing);

                ServiceDebugElement serviceDebug = new ServiceDebugElement();
                serviceDebug.IncludeExceptionDetailInFaults = false;
                behavior.Add(serviceDebug);

            }

        }
		public void ServiceDebugElement_defaults () {
			ServiceDebugElement element = new ServiceDebugElement ();

			Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
			Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");

			Assert.AreEqual (true, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
			Assert.AreEqual (null, element.HttpHelpPageUrl, "HttpHelpPageUrl");
			Assert.AreEqual (true, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
			Assert.AreEqual (null, element.HttpsHelpPageUrl, "HttpsHelpPageUrl");
			Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
		}
Example #5
0
        /// <summary>
        /// 获取启动服务参数
        /// </summary>
        /// <param name="implementsContractType">实体契约类的类型</param>
        /// <param name="interfaceContractType">契约类型</param>
        /// <param name="uri">服务地址</param>
        /// <param name="binding">启动服务类型</param>
        public void GetServiceConfig(Type implementsContractType, Type interfaceContractType, Uri uri, BindingType binding)
        {
            ImplementsContractType = implementsContractType;
            AddService(implementsContractType.ToString());
            ServiceEndpointElement item = new ServiceEndpointElement(uri, interfaceContractType.ToString());
            item.BindingConfiguration = item.Name = interfaceContractType.ToString();
            item.Binding = binding.ToString();

            ServiceElement service = serviceconfig.Services[implementsContractType.ToString()];
            service.Endpoints.Add(item);

            SetBindingParam(uri, binding, item.BindingConfiguration);

            if (!behaviorconfig.ServiceBehaviors.ContainsKey(service.BehaviorConfiguration))
            {
                ServiceBehaviorElement haviorelement = new ServiceBehaviorElement();// _setting.BehaviorConfig.ServiceBehaviors[service.BehaviorConfiguration];
                haviorelement.Name = service.BehaviorConfiguration;
                #region 并发设置
                //List<ServiceThrottlingElement> throttlingConfig = haviorelement.OfType<ServiceThrottlingElement>().ToList();
                ServiceThrottlingElement throttlingBehavior = new ServiceThrottlingElement();// host.Description.Behaviors.Find<ServiceThrottlingBehavior>();
                //当前ServiceHost能够处理的最大并发消息数量,默认值为16
                throttlingBehavior.MaxConcurrentCalls = int.MaxValue;
                //当前ServiceHost允许存在的InstanceContext的最大数量,默认值为26
                throttlingBehavior.MaxConcurrentInstances = int.MaxValue;
                //当前ServiceHost允许的最大并发会话数量,默认值为10
                throttlingBehavior.MaxConcurrentSessions = int.MaxValue;
                //throttlingConfig.Add(throttlingBehavior);
                haviorelement.Add(throttlingBehavior);
                #endregion

                #region 序列化最大项
                DataContractSerializerElement dataContractSerializerElement = new System.ServiceModel.Configuration.DataContractSerializerElement();
                dataContractSerializerElement.MaxItemsInObjectGraph = 2147483647;
                haviorelement.Add(dataContractSerializerElement);
                #endregion

                #region 是否充许客户端看到详细错误信息
                ServiceDebugElement debugConfig = new ServiceDebugElement();
                debugConfig.IncludeExceptionDetailInFaults = _isShowErrorInfoToClient;
                haviorelement.Add(debugConfig);
                #endregion

                behaviorconfig.ServiceBehaviors.Add(haviorelement);
            }
        }