// Konfiguracja z pliku private static void ChannelFactoryTest() { string endpointConfigurationName = "BasicHttpBinding_IHelloService"; ChannelFactory <IHelloServices.IHelloService> proxy = new ChannelFactory <IHelloServices.IHelloService>(endpointConfigurationName); IHelloServices.IHelloService helloService = proxy.CreateChannel(); helloService.Send("Hello World!"); string response = helloService.Ping("Hello World!"); int result = helloService.Add(1, 2); Console.WriteLine(result); Customer customer = helloService.Get(1); Console.WriteLine($"{customer.FirstName} {customer.LastName}"); }
// Konfiguracja z kodu private static void ChannelFactoryCodeTest() { Uri uri = new Uri(ConfigurationManager.AppSettings["HelloServiceAddress"]); BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress endpoint = new EndpointAddress(uri); ChannelFactory <IHelloServices.IHelloService> proxy = new ChannelFactory <IHelloServices.IHelloService>(binding, endpoint); IHelloServices.IHelloService helloService = proxy.CreateChannel(); helloService.Send("Hello World!"); string response = helloService.Ping("Hello World!"); int result = helloService.Add(1, 2); Console.WriteLine(result); Customer customer = helloService.Get(1); Console.WriteLine($"{customer.FirstName} {customer.LastName}"); }