static void Main(string[] args) { string baseAddress = "http://" + Environment.MachineName + ":8000/Service"; foreach (Type badServiceType in new Type[] { typeof(BadService1_NoDefaultCtor), typeof(BadService2_RefParameter) }) { try { new PocoServiceHost(badServiceType, new Uri(baseAddress)).Open(); Console.WriteLine("This line should not be reached"); } catch (InvalidOperationException e) { Console.WriteLine("Caught expected exception for service {0}: {1}", badServiceType.Name, e.Message); } } PocoServiceHost host = new PocoServiceHost(typeof(Service), new Uri(baseAddress)); host.Open(); ChannelFactory<ITest> factory = new ChannelFactory<ITest>(new BasicHttpBinding(), new EndpointAddress(baseAddress)); ITest proxy = factory.CreateChannel(); Console.WriteLine(proxy.Add(4, 5)); Console.WriteLine(proxy.Distance(new Point { X = 0, Y = 0 }, new Point { X = 3, Y = 4 })); Console.WriteLine("Press ENTER to close"); Console.ReadLine(); host.Close(); }
static void Main(string[] args) { string baseAddress = "http://" + Environment.MachineName + ":8000/Service"; foreach (Type badServiceType in new Type[] { typeof(BadService1_NoDefaultCtor), typeof(BadService2_RefParameter) }) { try { new PocoServiceHost(badServiceType, new Uri(baseAddress)).Open(); Console.WriteLine("This line should not be reached"); } catch (InvalidOperationException e) { Console.WriteLine("Caught expected exception for service {0}: {1}", badServiceType.Name, e.Message); } } PocoServiceHost host = new PocoServiceHost(typeof(Service), new Uri(baseAddress)); host.Open(); ChannelFactory <ITest> factory = new ChannelFactory <ITest>(new BasicHttpBinding(), new EndpointAddress(baseAddress)); ITest proxy = factory.CreateChannel(); Console.WriteLine(proxy.Add(4, 5)); Console.WriteLine(proxy.Distance(new Point { X = 0, Y = 0 }, new Point { X = 3, Y = 4 })); Console.WriteLine("Press ENTER to close"); Console.ReadLine(); host.Close(); }
static void Main(string[] args) { //string baseAddress = "http://localhost:8000/"; PocoServiceHost host = new PocoServiceHost(typeof(CalculatorService), new Uri("http://localhost:8000/PocoServiceHost/CalculatorService")); host.Open(); Console.WriteLine("Press ENTER to close"); Console.ReadLine(); host.Close(); }