static void Main(string[] args) { try { InstanceContext site = new InstanceContext(new CallbackHandler()); HelloClient proxy = new HelloClient(site); Console.WriteLine("Client"); proxy.HelloFromClient(); Console.ReadLine(); proxy.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main() { // Create a client. HelloClient client = new HelloClient(); // Add a reference-parameter header to the address. // Since the EndpointAddress class is immutable, we must use // EndpointAddressBuilder to change the value. EndpointAddressBuilder builder = new EndpointAddressBuilder(client.Endpoint.Address); AddressHeader header = AddressHeader.CreateAddressHeader(IDName, IDNamespace, "John"); builder.Headers.Add(header); client.Endpoint.Address = builder.ToEndpointAddress(); // Call the Hello service operation. Console.WriteLine(client.Hello()); //Closing the client gracefully closes the connection and cleans up resources client.Close(); Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); }
static void Main() { // Create a client. HelloClient client = new HelloClient(); // Add a reference-parameter header to the address. // Since the EndpointAddress class is immutable, we must use // EndpointAddressBuilder to change the value. EndpointAddressBuilder builder = new EndpointAddressBuilder(client.Endpoint.Address); AddressHeader header = AddressHeader.CreateAddressHeader(IDName, IDNamespace, "John"); builder.Headers.Add(header); client.Endpoint.Address = builder.ToEndpointAddress(); // Call the Hello service operation. Console.WriteLine(client.Hello()); //Closing the client gracefully closes the connection and cleans up resources client.Close(); Console.WriteLine(); Console.WriteLine("Press <ENTER> to terminate client."); Console.ReadLine(); }