public void DefaultValues () { var se = new ServiceMetadataEndpoint (); Assert.IsNotNull (se.Contract, "#1"); Assert.AreEqual (typeof (IMetadataExchange), se.Contract.ContractType, "#1.2"); Assert.IsNotNull (se.Binding, "#2"); // FIXME: enable once we get usable WSHttpBinding. // Assert.AreEqual (typeof (WSHttpBinding), se.Binding.GetType (), "#2.2"); Assert.IsNull (se.Address, "#3"); }
static void Main(string[] args) { string baseAddress = GetIpAdress(); while (baseAddress == "") { Console.WriteLine("No Connection with local network, Connect and press <enter>"); Console.ReadLine(); baseAddress = GetIpAdress(); } // creeer een host proces voor de TrafficMessageService ServiceHost host = new ServiceHost(typeof(CTrafficMessage)); // creeer een zgn. end-point voor de service Type contract = typeof(ITrafficMessage); BasicHttpBinding binding = new BasicHttpBinding(); Uri address = new Uri(baseAddress + "/MessageService"); host.AddServiceEndpoint(contract, binding, address); // creeer een zgn. mex endpoint om de wsdl van de service te hosten host.Description.Behaviors.Add(new ServiceMetadataBehavior()); EndpointAddress endPointAddress = new EndpointAddress(baseAddress + "/MEX"); ServiceEndpoint mexEndpoint = new ServiceMetadataEndpoint(endPointAddress); host.AddServiceEndpoint(mexEndpoint); try { // start de service host.Open(); // hou het proces in de lucht tot de gebruiker op enter drukt Console.WriteLine("Service ITrafficMessage successfully hosted at address: "); Console.WriteLine(baseAddress + "/MEX"); Console.WriteLine("\nPress <enter> to end the service..."); Console.ReadLine(); } catch (TimeoutException timeProblem) { Console.WriteLine(timeProblem.Message); Console.ReadLine(); } catch (CommunicationException commProblem) { Console.WriteLine(commProblem.Message + "\n"); Console.WriteLine("Are you running this as an administrator?"); Console.ReadLine(); } }
static void Main() { Program._Administration = new Administration(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ip = "localhost:8000"; if (!File.Exists("bind.txt")) { File.Create("bind.txt"); } if (File.Exists("bind.txt")) { try { string temp = File.ReadAllText("bind.txt"); if (!string.IsNullOrEmpty(temp) && !string.IsNullOrWhiteSpace(temp) && temp.Length > 2) { ip = temp; } } catch(Exception) { } } ServerGUI gui = new ServerGUI(); ControlWriter consoleWriter = new ControlWriter(gui.infoText); Console.SetOut(consoleWriter); // creeer een host proces voor de TrafficMessageService ServiceHost host = new ServiceHost(typeof(CTrafficMessage)); // creeer een zgn. end-point voor de service Type contract = typeof(ITrafficMessage); BasicHttpBinding binding = new BasicHttpBinding(); string baseAddress = "http://" + ip + "/MEX"; Uri address = new Uri(baseAddress + "/MessageService"); host.AddServiceEndpoint(contract, binding, address); // creeer een zgn. mex endpoint om de wsdl van de service te hosten host.Description.Behaviors.Add(new ServiceMetadataBehavior()); EndpointAddress endPointAddress = new EndpointAddress(baseAddress + "/MEX"); ServiceEndpoint mexEndpoint = new ServiceMetadataEndpoint(endPointAddress); host.AddServiceEndpoint(mexEndpoint); ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>(); // if not found - add behavior with setting turned on if (debug == null) { host.Description.Behaviors.Add( new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); } else { // make sure setting is turned ON if (!debug.IncludeExceptionDetailInFaults) { debug.IncludeExceptionDetailInFaults = true; } } // start de service host.Open(); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; _ITTF_SERVER_CONTROL_FORM = new ITTF_SERVER_CONTROL_FORM(); _ITTF_SERVER_CONTROL_FORM.Show(); _rawinput = new CRawInput(gui.Handle, CaptureOnlyInForeground); _rawinput.AddMessageFilter(); // Adding a message filter will cause keypresses to be handled _rawinput.KeyPressed += OnKeyPressed; new AdministrationForm().Show(); Application.Run(gui); _CTrafficMessage.Bye(); }