Ejemplo n.º 1
0
 void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     if (description == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("description"));
     }
     if (serviceHostBase == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceHostBase"));
     }
     for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
     {
         ChannelDispatcher dispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
         if (dispatcher != null)
         {
             foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints)
             {
                 if (!dispatcher2.IsSystemEndpoint)
                 {
                     DispatchRuntime dispatchRuntime = dispatcher2.DispatchRuntime;
                     dispatchRuntime.SecurityAuditLogLocation        = this.auditLogLocation;
                     dispatchRuntime.SuppressAuditFailure            = this.suppressAuditFailure;
                     dispatchRuntime.ServiceAuthorizationAuditLevel  = this.serviceAuthorizationAuditLevel;
                     dispatchRuntime.MessageAuthenticationAuditLevel = this.messageAuthenticationAuditLevel;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     if (description == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("description"));
     }
     if (serviceHostBase == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceHostBase"));
     }
     for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
     {
         ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
         if ((channelDispatcher != null) && !ServiceMetadataBehavior.IsHttpGetMetadataDispatcher(description, channelDispatcher))
         {
             foreach (EndpointDispatcher dispatcher2 in channelDispatcher.Endpoints)
             {
                 DispatchRuntime dispatchRuntime = dispatcher2.DispatchRuntime;
                 dispatchRuntime.PrincipalPermissionMode = this.principalPermissionMode;
                 if (!dispatcher2.IsSystemEndpoint)
                 {
                     dispatchRuntime.ImpersonateCallerForAllOperations = this.impersonateCallerForAllOperations;
                 }
                 if (this.roleProvider != null)
                 {
                     this.ApplyRoleProvider(dispatchRuntime);
                 }
                 if (this.isAuthorizationManagerSet || this.isExternalPoliciesSet)
                 {
                     this.ApplyAuthorizationPoliciesAndManager(dispatchRuntime);
                 }
             }
         }
     }
 }
        private static void AddBehaviors(System.ServiceModel.Description.ServiceDescription serviceDescription)
        {
            Type serviceType = serviceDescription.ServiceType;

            TypeLoader.ApplyServiceInheritance <IServiceBehavior, KeyedByTypeCollection <IServiceBehavior> >(serviceType, serviceDescription.Behaviors, new TypeLoader.ServiceInheritanceCallback <IServiceBehavior, KeyedByTypeCollection <IServiceBehavior> >(System.ServiceModel.Description.ServiceDescription.GetIServiceBehaviorAttributes));
            ServiceBehaviorAttribute attribute = EnsureBehaviorAttribute(serviceDescription);

            if (attribute.Name != null)
            {
                serviceDescription.Name = new XmlName(attribute.Name).EncodedName;
            }
            if (attribute.Namespace != null)
            {
                serviceDescription.Namespace = attribute.Namespace;
            }
            if (string.IsNullOrEmpty(attribute.ConfigurationName))
            {
                serviceDescription.ConfigurationName = serviceType.FullName;
            }
            else
            {
                serviceDescription.ConfigurationName = attribute.ConfigurationName;
            }
            AspNetEnvironment.Current.EnsureCompatibilityRequirements(serviceDescription);
        }
        public void ApplyDispatchBehavior_AppliesCorrectInstanceProvider()
        {
            Mock<IUnityContainer> containerMock = new Mock<IUnityContainer>();
            DataServiceDependencyInstanceProvider expectedResult = new DataServiceDependencyInstanceProvider(containerMock.Object, typeof(int));
            containerMock.Setup(a => a.Resolve(typeof(DataServiceDependencyInstanceProvider), null, It.IsAny<ResolverOverride[]>())).Returns(expectedResult);
            System.ServiceModel.Description.IServiceBehavior target = new DataServiceDependencyBehavior(containerMock.Object);
            var host = new DummyServiceHost();
            var serviceDescription = new System.ServiceModel.Description.ServiceDescription();
            serviceDescription.ServiceType = typeof(int);

            target.ApplyDispatchBehavior(serviceDescription, host);

            foreach (var cd in host.ChannelDispatchers)
            {
                foreach (var ep in (cd as DummyChannelDispatcher).Endpoints)
                {
                    var instanceProvider = (host.ChannelDispatchers[0] as DummyChannelDispatcher).Endpoints[0].DispatchRuntime.InstanceProvider;

                    Assert.IsNotNull(instanceProvider, @"
            The instanceProvider should not be null because the behavior should have set it up.
            ");
                    Assert.AreEqual(expectedResult, instanceProvider, @"
            The instance provider is an instance of an object that wasn't expected.
            ");
                }
            }
        }
Ejemplo n.º 5
0
 void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     if (description == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("description"));
     }
     if (serviceHostBase == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceHostBase"));
     }
     if (this.serviceAuthenticationManager != null)
     {
         for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
         {
             ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
             if ((channelDispatcher != null) && !ServiceMetadataBehavior.IsHttpGetMetadataDispatcher(description, channelDispatcher))
             {
                 foreach (EndpointDispatcher dispatcher2 in channelDispatcher.Endpoints)
                 {
                     DispatchRuntime dispatchRuntime = dispatcher2.DispatchRuntime;
                     dispatchRuntime.ServiceAuthenticationManager = this.serviceAuthenticationManager;
                     ServiceEndpoint endpoint = this.FindMatchingServiceEndpoint(description, dispatcher2);
                     if ((endpoint != null) && this.IsSecureConversationBinding(endpoint.Binding))
                     {
                         SecurityStandardsManager configuredSecurityStandardsManager = this.GetConfiguredSecurityStandardsManager(endpoint.Binding);
                         dispatchRuntime.ServiceAuthenticationManager = new ServiceAuthenticationManagerWrapper(this.serviceAuthenticationManager, new string[] { configuredSecurityStandardsManager.SecureConversationDriver.CloseAction.Value });
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters)
 {
     if (parameters == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parameters"));
     }
     parameters.Add(this);
 }
Ejemplo n.º 7
0
 void System.ServiceModel.Description.IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
 {
     // add the error handler to the list
     foreach (System.ServiceModel.Dispatcher.ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
     {
         channelDispatcher.ErrorHandlers.Add(this);
     }
 }
        private void ApplyBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase host)
        {
            ServiceMetadataExtension mex = ServiceMetadataExtension.EnsureServiceMetadataExtension(description, host);

            this.SetExtensionProperties(description, host, mex);
            CustomizeMetadataEndpoints(description, host, mex);
            this.CreateHttpGetEndpoints(description, host, mex);
        }
 internal static bool IsMetadataImplementedType(System.ServiceModel.Description.ServiceDescription description, System.Type type)
 {
     if (BehaviorMissingObjectNullOrServiceImplements(description, type))
     {
         return(false);
     }
     return(type == typeof(IMetadataExchange));
 }
 internal static bool IsMetadataEndpoint(System.ServiceModel.Description.ServiceDescription description, ServiceEndpoint endpoint)
 {
     if (BehaviorMissingObjectNullOrServiceImplements(description, endpoint))
     {
         return(false);
     }
     return(IsMetadataEndpoint(endpoint));
 }
        private static ServiceBehaviorAttribute EnsureBehaviorAttribute(System.ServiceModel.Description.ServiceDescription description)
        {
            ServiceBehaviorAttribute item = description.Behaviors.Find <ServiceBehaviorAttribute>();

            if (item == null)
            {
                item = new ServiceBehaviorAttribute();
                description.Behaviors.Insert(0, item);
            }
            return(item);
        }
 public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription,
                                   System.ServiceModel.ServiceHostBase serviceHostBase)
 {
     foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers)
     {
         foreach (var endpointDispatcher in channelDispatcher.Endpoints)
         {
             endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new MyServiceMessageInspector());
         }
     }
 }
 private void CreateHelpPageEndpoints(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
 {
     if (this.httpHelpPageEnabled && !this.EnsureHelpPageDispatcher(host, mex, this.httpHelpPageUrl, Uri.UriSchemeHttp))
     {
         TraceWarning(this.httpHelpPageUrl, "ServiceDebugBehaviorHttpHelpPageUrl", "ServiceDebugBehaviorHttpHelpPageEnabled");
     }
     if (this.httpsHelpPageEnabled && !this.EnsureHelpPageDispatcher(host, mex, this.httpsHelpPageUrl, Uri.UriSchemeHttps))
     {
         TraceWarning(this.httpHelpPageUrl, "ServiceDebugBehaviorHttpsHelpPageUrl", "ServiceDebugBehaviorHttpsHelpPageEnabled");
     }
 }
 private void CreateHttpGetEndpoints(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
 {
     if (this.httpGetEnabled)
     {
         EnsureGetDispatcher(host, mex, this.httpGetUrl, Uri.UriSchemeHttp);
     }
     if (this.httpsGetEnabled)
     {
         EnsureGetDispatcher(host, mex, this.httpsGetUrl, Uri.UriSchemeHttps);
     }
 }
Ejemplo n.º 15
0
 private ServiceEndpoint FindMatchingServiceEndpoint(System.ServiceModel.Description.ServiceDescription description, EndpointDispatcher endpointDispatcher)
 {
     foreach (ServiceEndpoint endpoint in description.Endpoints)
     {
         if (endpoint.Address.Equals(endpointDispatcher.EndpointAddress))
         {
             return(endpoint);
         }
     }
     return(null);
 }
 void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     if (description == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
     }
     if (serviceHostBase == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceHostBase");
     }
     this.ApplyBehavior(description, serviceHostBase);
 }
 private static bool IsMetadataTransferDispatcher(System.ServiceModel.Description.ServiceDescription description, ChannelDispatcher channelDispatcher)
 {
     if (!BehaviorMissingObjectNullOrServiceImplements(description, channelDispatcher))
     {
         foreach (EndpointDispatcher dispatcher in channelDispatcher.Endpoints)
         {
             if ((dispatcher.ContractName == "IMetadataExchange") && (dispatcher.ContractNamespace == "http://schemas.microsoft.com/2006/04/mex"))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     if (this.transactionTimeout != TimeSpan.Zero)
     {
         for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
         {
             ChannelDispatcher dispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
             if (((dispatcher != null) && dispatcher.HasApplicationEndpoints()) && ((dispatcher.TransactionTimeout == TimeSpan.Zero) || (dispatcher.TransactionTimeout > this.transactionTimeout)))
             {
                 dispatcher.TransactionTimeout = this.transactionTimeout;
             }
         }
     }
 }
 internal static bool IsHttpGetMetadataDispatcher(System.ServiceModel.Description.ServiceDescription description, ChannelDispatcher channelDispatcher)
 {
     if (description.Behaviors.Find <ServiceMetadataBehavior>() != null)
     {
         foreach (EndpointDispatcher dispatcher in channelDispatcher.Endpoints)
         {
             if ((dispatcher.ContractName == "IHttpGetHelpPageAndMetadataContract") && (dispatcher.ContractNamespace == "http://schemas.microsoft.com/2006/04/http/metadata"))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters)
        {
            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            SecurityCredentialsManager manager = parameters.Find <SecurityCredentialsManager>();

            if (manager != null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleSecurityCredentialsManagersInServiceBindingParameters", new object[] { manager })));
            }
            parameters.Add(this);
        }
Ejemplo n.º 21
0
        public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
        {
            IErrorHandler handler = (IErrorHandler)Activator.CreateInstance(this.errorHandlerType);

            foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
            {
                ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher;
                if (channelDispatcher != null)
                {
                    channelDispatcher.ErrorHandlers.Add(handler);
                }
            }

            //throw new NotImplementedException();
        }
 internal static bool IsMetadataDispatcher(System.ServiceModel.Description.ServiceDescription description, ChannelDispatcher channelDispatcher)
 {
     using (IEnumerator <EndpointDispatcher> enumerator = channelDispatcher.Endpoints.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             EndpointDispatcher current = enumerator.Current;
             if (IsMetadataTransferDispatcher(description, channelDispatcher) || IsHttpGetMetadataDispatcher(description, channelDispatcher))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 public static System.ServiceModel.Description.ServiceDescription GetService(Type serviceType)
 {
     if (serviceType == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType");
     }
     if (!serviceType.IsClass)
     {
         throw new ArgumentException(System.ServiceModel.SR.GetString("SFxServiceHostNeedsClass"));
     }
     System.ServiceModel.Description.ServiceDescription serviceDescription = new System.ServiceModel.Description.ServiceDescription {
         ServiceType = serviceType
     };
     AddBehaviors(serviceDescription);
     SetupSingleton(serviceDescription, null, false);
     return(serviceDescription);
 }
        private static void SetupSingleton(System.ServiceModel.Description.ServiceDescription serviceDescription, object implementation, bool isWellKnown)
        {
            ServiceBehaviorAttribute attribute = EnsureBehaviorAttribute(serviceDescription);
            Type serviceType = serviceDescription.ServiceType;

            if ((implementation == null) && (attribute.InstanceContextMode == InstanceContextMode.Single))
            {
                implementation = CreateImplementation(serviceType);
            }
            if (isWellKnown)
            {
                attribute.SetWellKnownSingleton(implementation);
            }
            else if ((implementation != null) && (attribute.InstanceContextMode == InstanceContextMode.Single))
            {
                attribute.SetHiddenSingleton(implementation);
            }
        }
        public static System.ServiceModel.Description.ServiceDescription GetService(object serviceImplementation)
        {
            if (serviceImplementation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceImplementation");
            }
            Type type = serviceImplementation.GetType();

            System.ServiceModel.Description.ServiceDescription serviceDescription = new System.ServiceModel.Description.ServiceDescription {
                ServiceType = type
            };
            if (serviceImplementation is IServiceBehavior)
            {
                serviceDescription.Behaviors.Add((IServiceBehavior)serviceImplementation);
            }
            AddBehaviors(serviceDescription);
            SetupSingleton(serviceDescription, serviceImplementation, true);
            return(serviceDescription);
        }
 void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     if (this.includeExceptionDetailInFaults)
     {
         for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
         {
             ChannelDispatcher dispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
             if (dispatcher != null)
             {
                 dispatcher.IncludeExceptionDetailInFaults = true;
             }
         }
     }
     if (this.httpHelpPageEnabled || this.httpsHelpPageEnabled)
     {
         ServiceMetadataExtension mex = ServiceMetadataExtension.EnsureServiceMetadataExtension(description, serviceHostBase);
         this.SetExtensionProperties(mex, serviceHostBase);
         this.CreateHelpPageEndpoints(description, serviceHostBase, mex);
     }
 }
 private static void CustomizeMetadataEndpoints(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
 {
     for (int i = 0; i < host.ChannelDispatchers.Count; i++)
     {
         ChannelDispatcher channelDispatcher = host.ChannelDispatchers[i] as ChannelDispatcher;
         if ((channelDispatcher != null) && IsMetadataTransferDispatcher(description, channelDispatcher))
         {
             if (channelDispatcher.Endpoints.Count != 1)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxServiceMetadataBehaviorInstancingError", new object[] { channelDispatcher.Listener.Uri, channelDispatcher.CreateContractListString() })));
             }
             DispatchRuntime dispatchRuntime = channelDispatcher.Endpoints[0].DispatchRuntime;
             dispatchRuntime.InstanceContextProvider = InstanceContextProviderBase.GetProviderForMode(InstanceContextMode.Single, dispatchRuntime);
             bool isListeningOnHttps = channelDispatcher.Listener.Uri.Scheme == Uri.UriSchemeHttps;
             Uri  listenUri          = channelDispatcher.Listener.Uri;
             ServiceMetadataExtension.WSMexImpl implementation = new ServiceMetadataExtension.WSMexImpl(mex, isListeningOnHttps, listenUri);
             dispatchRuntime.SingletonInstanceContext = new InstanceContext(host, implementation, false);
         }
     }
 }
        void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase)
        {
            if (serviceHostBase == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceHostBase"));
            }
            ServiceThrottle serviceThrottle = serviceHostBase.ServiceThrottle;

            serviceThrottle.MaxConcurrentCalls     = this.calls;
            serviceThrottle.MaxConcurrentSessions  = this.sessions;
            serviceThrottle.MaxConcurrentInstances = this.MaxConcurrentInstances;
            for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
            {
                ChannelDispatcher dispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
                if (dispatcher != null)
                {
                    dispatcher.ServiceThrottle = serviceThrottle;
                }
            }
        }
Ejemplo n.º 29
0
        private void FixupConfig(System.ServiceModel.Description.ServiceDescription serviceDescription)
        {
            foreach (var endpoint in serviceDescription.Endpoints)
            {
                var binding = endpoint.Binding;
                var web     = binding as WebHttpBinding;

                if (web != null)
                {
                    web.MaxBufferSize          = 2147483647;
                    web.MaxReceivedMessageSize = 2147483647;
                }

                var myReaderQuotas = new XmlDictionaryReaderQuotas {
                    MaxStringContentLength = 2147483647
                };

                binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, myReaderQuotas, null);
            }
        }
        private void SetExtensionProperties(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase host, ServiceMetadataExtension mex)
        {
            mex.ExternalMetadataLocation = this.ExternalMetadataLocation;
            mex.Initializer     = new MetadataExtensionInitializer(this, description, host);
            mex.HttpGetEnabled  = this.httpGetEnabled;
            mex.HttpsGetEnabled = this.httpsGetEnabled;
            mex.HttpGetUrl      = host.GetVia(Uri.UriSchemeHttp, (this.httpGetUrl == null) ? new Uri(string.Empty, UriKind.Relative) : this.httpGetUrl);
            mex.HttpsGetUrl     = host.GetVia(Uri.UriSchemeHttps, (this.httpsGetUrl == null) ? new Uri(string.Empty, UriKind.Relative) : this.httpsGetUrl);
            mex.HttpGetBinding  = this.httpGetBinding;
            mex.HttpsGetBinding = this.httpsGetBinding;
            UseRequestHeadersForMetadataAddressBehavior behavior = description.Behaviors.Find <UseRequestHeadersForMetadataAddressBehavior>();

            if (behavior != null)
            {
                mex.UpdateAddressDynamically = true;
                mex.UpdatePortsByScheme      = new Dictionary <string, int>(behavior.DefaultPortsByScheme);
            }
            foreach (ChannelDispatcherBase base2 in host.ChannelDispatchers)
            {
                ChannelDispatcher channelDispatcher = base2 as ChannelDispatcher;
                if ((channelDispatcher != null) && IsMetadataTransferDispatcher(description, channelDispatcher))
                {
                    mex.MexEnabled = true;
                    mex.MexUrl     = channelDispatcher.Listener.Uri;
                    if (behavior != null)
                    {
                        foreach (EndpointDispatcher dispatcher2 in channelDispatcher.Endpoints)
                        {
                            if (!dispatcher2.AddressFilterSetExplicit)
                            {
                                dispatcher2.AddressFilter = new MatchAllMessageFilter();
                            }
                        }
                    }
                    break;
                }
            }
        }
Ejemplo n.º 31
0
        public void ConfigureService(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
        {
            var host = (serviceHostBase as ServiceHost);

            if (host != null)
            {
                // Don't use this crappy binding
                var address  = serviceHostBase.Description.Endpoints.First().Address;
                var contract = serviceHostBase.Description.Endpoints.First().Contract;

                // clear existing
                host.Description.Endpoints.Clear();

                var binding = new WS2007HttpBinding();
                binding.Security.Mode = SecurityMode.None;

                MaxSetter.SetMaxes(binding);

                host.AddServiceEndpoint(contract.ContractType, binding, address.Uri);
            }

            DisableErrorMasking.Disable(serviceHostBase);
        }
 internal MetadataExtensionInitializer(ServiceMetadataBehavior behavior, System.ServiceModel.Description.ServiceDescription description, ServiceHostBase host)
 {
     this.behavior = behavior;
     this.description = description;
     this.host = host;
 }
 public static System.ServiceModel.Description.ServiceDescription GetService(Type serviceType)
 {
     if (serviceType == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType");
     }
     if (!serviceType.IsClass)
     {
         throw new ArgumentException(System.ServiceModel.SR.GetString("SFxServiceHostNeedsClass"));
     }
     System.ServiceModel.Description.ServiceDescription serviceDescription = new System.ServiceModel.Description.ServiceDescription {
         ServiceType = serviceType
     };
     AddBehaviors(serviceDescription);
     SetupSingleton(serviceDescription, null, false);
     return serviceDescription;
 }
 public static System.ServiceModel.Description.ServiceDescription GetService(object serviceImplementation)
 {
     if (serviceImplementation == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceImplementation");
     }
     Type type = serviceImplementation.GetType();
     System.ServiceModel.Description.ServiceDescription serviceDescription = new System.ServiceModel.Description.ServiceDescription {
         ServiceType = type
     };
     if (serviceImplementation is IServiceBehavior)
     {
         serviceDescription.Behaviors.Add((IServiceBehavior) serviceImplementation);
     }
     AddBehaviors(serviceDescription);
     SetupSingleton(serviceDescription, serviceImplementation, true);
     return serviceDescription;
 }