static void Main(string[] args) { BindingElementCollection elements = new BindingElementCollection(); elements.Add(new TransactionFlowBindingElement(TransactionProtocol.WSAtomicTransactionOctober2004)); elements.Add(new ReliableSessionBindingElement(true)); elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8)); elements.Add(new HttpTransportBindingElement()); CustomBinding binding = new CustomBinding(elements); ChannelFactory <IHelloIndigoService> factory = new ChannelFactory <IHelloIndigoService>(binding, "http://localhost:8000/HelloIndigoService"); IHelloIndigoService proxy = null; try { proxy = factory.CreateChannel(); { string s = proxy.HelloIndigo("hello"); Console.WriteLine(s); Console.ReadLine(); } } finally { ICommunicationObject obj = proxy as ICommunicationObject; if (obj != null) { obj.Close(); } } }
static void Main(string[] args) { Console.WriteLine("Client running on thread {0}", Thread.CurrentThread.GetHashCode()); Console.WriteLine(); CallbackType cb = new CallbackType(); InstanceContext context = new InstanceContext(cb); WSDualHttpBinding binding = new WSDualHttpBinding(); binding.ClientBaseAddress = new Uri("http://localhost:8100"); DuplexChannelFactory <IHelloIndigoService> factory = new DuplexChannelFactory <IHelloIndigoService>(context, binding, new EndpointAddress("http://localhost:8000/wsDual")); IHelloIndigoService proxy = factory.CreateChannel(); try { Console.WriteLine("Calling HelloIndigo() - one-way"); proxy.HelloIndigo("Hello from client."); Console.WriteLine("Returned from HelloIndigo()"); Console.WriteLine("Calling HelloIndigo() - not one-way"); proxy.HelloIndigo2("Hello from client."); Console.WriteLine("Returned from HelloIndigo()"); Console.ReadLine(); } finally { ICommunicationObject obj = proxy as ICommunicationObject; obj.Close(); } }
static void Main(string[] args) { EndpointAddress ep = new EndpointAddress("http://localhost:8000/HelloIndigo/HelloIndigoService"); IHelloIndigoService proxy = ChannelFactory <IHelloIndigoService> .CreateChannel(new BasicHttpBinding(), ep); string s = proxy.HelloIndigo(); Console.WriteLine(s); Console.WriteLine("Press <ENTER> to terminate Client."); Console.ReadLine(); }