/// <summary> /// Set the parameters of the service and then host it. /// </summary> public void StartService() { Console.Write("Starting " + NodeName + " node in " + NodeGeoName + "... "); // Set address, binding, contract and behavior of the Service Uri http_uri = new Uri(baseHTTPAddress + NodeName); Uri mobile_uri = new Uri(baseMobileAddress + NodeName); Uri fwd_uri = new Uri(baseForwardAddress + NodeName); WSDualHttpBinding http_binding = new WSDualHttpBinding(); BasicHttpBinding mobile_binding = new BasicHttpBinding(); BasicHttpBinding fwd_binding = new BasicHttpBinding(); Type darPoolingContract = typeof(IDarPooling); Type darPoolingForwardingContract = typeof(IDarPoolingForwarding); Type darPoolingMobileContract = typeof(IDarPoolingMobile); ServiceMetadataBehavior mex_behavior = new ServiceMetadataBehavior(); mex_behavior.HttpGetEnabled = true; // Hosting the services serviceHost = new ServiceHost(serviceImpl, http_uri); //serviceHost.AddServiceEndpoint(darPoolingMobileContract, mobile_binding, ""); serviceHost.AddServiceEndpoint(darPoolingContract, http_binding, ""); serviceHost.AddServiceEndpoint(darPoolingForwardingContract, fwd_binding, fwd_uri); serviceHost.Description.Behaviors.Add(mex_behavior); serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); mobileServiceHost = new ServiceHost(mobileServiceImpl, mobile_uri); mobileServiceHost.AddServiceEndpoint(darPoolingMobileContract, mobile_binding, ""); mobileServiceHost.Description.Behaviors.Add(mex_behavior); mobileServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); // Run the service serviceHost.Open(); mobileServiceHost.Open(); // Start the daemons in the service serviceImpl.StartTimers(); Console.WriteLine("OK!"); }