void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            ServiceHost host = serviceHostBase as ServiceHost;

            host.AddGenericResolver();
        }
示例#2
0
 public HostRecord(ServiceHost host, string address)
 {
     Host    = host;
     Address = new EndpointAddress(address);
 }
示例#3
0
 /// <summary>
 ///  Can only call before openning the host
 /// </summary>
 public static void SetThreadAffinity(this ServiceHost host)
 {
     SetThreadAffinity(host, "Executing all endpoints of " + host.Description.ServiceType);
 }
 /// <summary>
 ///  Can only call before openning the host
 /// </summary>
 public static void SetAsyncContext(this ServiceHost host, uint poolSize)
 {
     SetAsyncContext(host, poolSize, "Executing all endpoints of " + host.Description.ServiceType);
 }
 /// <summary>
 /// Can only call before openning the host. Does not override config values if present 
 /// </summary>
 public static void SetThrottle(this ServiceHost host,ServiceThrottlingBehavior serviceThrottle)
 {
    host.SetThrottle(serviceThrottle,false);
 }
示例#6
0
 /// <summary>
 /// Can only call before openning the host
 /// </summary>
 /// <param name="mode">Certificate is looked up by name from LocalMachine/My store</param>
 public static void SetSecurityBehavior(this ServiceHost host, ServiceSecurity mode, string serviceCertificateName, bool useAspNetProviders, string applicationName, bool impersonateAll = false)
 {
     SetSecurityBehavior(host, mode, StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, serviceCertificateName, useAspNetProviders, applicationName, impersonateAll);
 }
示例#7
0
        public static void EnableDiscovery(this ServiceHost host, Uri scope, bool enableMEX = true)
        {
            if (host.Description.Endpoints.Count == 0)
            {
                host.AddDefaultEndpoints();
            }
            host.AddServiceEndpoint(new UdpDiscoveryEndpoint());

            ServiceDiscoveryBehavior discovery = new ServiceDiscoveryBehavior();

            discovery.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
            host.Description.Behaviors.Add(discovery);

            if (enableMEX == true)
            {
                host.Description.Behaviors.Add(new ServiceMetadataBehavior());

                foreach (Uri baseAddress in host.BaseAddresses)
                {
                    Binding binding = null;

                    if (baseAddress.Scheme == "net.tcp")
                    {
                        binding = MetadataExchangeBindings.CreateMexTcpBinding();
                    }
                    if (baseAddress.Scheme == "net.pipe")
                    {
                        binding = MetadataExchangeBindings.CreateMexNamedPipeBinding();
                    }
                    if (baseAddress.Scheme == "http")
                    {
                        binding = MetadataExchangeBindings.CreateMexHttpBinding();
                    }
                    if (baseAddress.Scheme == "https")
                    {
                        binding = MetadataExchangeBindings.CreateMexHttpsBinding();
                    }
                    if (baseAddress.Scheme == "sb")
                    {
                        binding = new NetTcpRelayBinding();
                    }
                    Debug.Assert(binding != null);
                    if (binding != null)
                    {
                        host.AddServiceEndpoint(typeof(IMetadataExchange), binding, "MEX");
                    }
                }
            }
            if (scope != null)
            {
                EndpointDiscoveryBehavior behavior = new EndpointDiscoveryBehavior();
                behavior.Scopes.Add(scope);

                foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
                {
                    if (endpoint.IsSystemEndpoint ||
                        endpoint is DiscoveryEndpoint ||
                        endpoint is AnnouncementEndpoint ||
                        endpoint is ServiceMetadataEndpoint)
                    {
                        continue;
                    }
                    endpoint.Behaviors.Add(behavior);
                }
            }
        }
示例#8
0
 public static void EnableDiscovery(this ServiceHost host, bool enableMEX = true)
 {
     EnableDiscovery(host, null, enableMEX);
 }