public void Run() { try { //ServiceHost host = new ServiceHost(typeof(QuerySvc)); //host.AddServiceEndpoint(typeof(IQuerySvc), new WSHttpBinding(), "http://127.0.0.1:9999/QuerySvc"); //if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null) //{ // ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); // behavior.HttpGetEnabled = true; // behavior.HttpGetUrl = new Uri("http://127.0.0.1:9999/QuerySvc/metadata"); // host.Description.Behaviors.Add(behavior); //} //host.Open(); Publishing pub = new Publishing(); Thread thread = new Thread(pub.HeartBeatLink); thread.Start(); HostPublishService(); HostSubscriptionService(); } catch { } }
protected override void OnStart(string[] args) { log.Info("PubSubSvc started " + DateTime.Now.ToString()); Publishing pub = new Publishing(); Thread thread = new Thread(pub.HeartBeatLink); thread.Start(); // TODO: Add code here to start your service. try { ServiceHost host = new ServiceHost(typeof(QuerySvc)); host.AddServiceEndpoint(typeof(IQuerySvc), new WSHttpBinding(), "http://127.0.0.1:9999/QuerySvc"); if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null) { ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; behavior.HttpGetUrl = new Uri("http://127.0.0.1:9999/QuerySvc/metadata"); host.Description.Behaviors.Add(behavior); } host.Open(); HostPublishService(); HostSubscriptionService(); } catch(Exception ex) { log.Error(ex); } }