static void StartWCFService(HostSettingsDataItem hostSettings) { ServiceHost host = new ServiceHost(typeof(WCF_NO_SSL), new Uri(hostSettings.address)); foreach (ServiceEndpoint ep in host.Description.Endpoints) { ep.Behaviors.Add(new BehaviorAttribute()); ep.Binding.OpenTimeout = new TimeSpan(0, 10, 0); ep.Binding.CloseTimeout = new TimeSpan(0, 10, 0); ep.Binding.SendTimeout = new TimeSpan(0, 10, 0); ep.Binding.ReceiveTimeout = new TimeSpan(0, 10, 0); } host.Open(); Console.WriteLine("Http service is opened"); Console.WriteLine("Press ctrl+c for close"); }
static void StartSSLWCFService(HostSettingsDataItem hostSettings) { ServiceHost host = new ServiceHost(typeof(WCF_WITH_SSL), new Uri(hostSettings.address)); foreach (ServiceEndpoint ep in host.Description.Endpoints) { ep.Behaviors.Add(new BehaviorAttribute()); } host.Credentials.ServiceCertificate.SetCertificate( StoreLocation.CurrentUser, StoreName.Root, X509FindType.FindByIssuerName, Cert.USER ); host.Open(); string address = host.Description.Endpoints[0].ListenUri.AbsoluteUri; Console.WriteLine("Https service is opened"); Console.WriteLine("Press any key to continue"); Console.ReadLine(); host.Close(); }