using System; using System.ServiceModel; using System.ServiceModel.Description; namespace AIPractice.LabellerServer { class LabellerServer { private ServiceHost _host; public void Start() { Uri baseAddress = new Uri("http://localhost:8866/LabellerService"); // Create the ServiceHost. _host = new ServiceHost(typeof(LabellerService), baseAddress); var basicHttpBinding = new BasicHttpBinding(); basicHttpBinding.MaxReceivedMessageSize = int.MaxValue; basicHttpBinding.MaxBufferSize = int.MaxValue; basicHttpBinding.MaxBufferPoolSize = int.MaxValue; _host.AddServiceEndpoint(typeof(IAccountService), basicHttpBinding, baseAddress); _host.AddServiceEndpoint(typeof(ILabelService), basicHttpBinding, baseAddress); _host.AddServiceEndpoint(typeof(IUpgradeService), basicHttpBinding, baseAddress); _host.AddServiceEndpoint(typeof(IReviewService), basicHttpBinding, baseAddress); // Enable metadata publishing. ServiceMetadataBehavior smb = new ServiceMetadataBehavior { HttpGetEnabled = true, }; smb.MetadataExporter.PolicyVersion = PolicyVersion.Default; _host.Description.Behaviors.Add(smb); // Open the ServiceHost to start listening for messages. Since // no endpoints are explicitly configured, the runtime will create // one endpoint per base address for each service contract implemented // by the service. _host.Open(); } public void Stop() { _host?.Close(); _host = null; } } }