Using a WCF Client
This is the sixth and the final step for using a WCF client. In the previous tutorial: Configuring a WCF Client we added the auto-generated the wcfServiceProxy.cs and app.config file into the WCFService_Client application to configure the endpoints for the WCF client. Now our client application is ready to access the WCF client and consume the service contracts. The Windows Communication Foundation (WCF) proxy class included inside the client application it enables to initialize the client instance that further allows consuming the service contracts exposed by the WCF service.
The code required for using a WCF client must be placed inside the Main() method of program.cs class file of the client application.
C# Code to Use WCF Client
1. It is an optional step to specify the endpoint programmatically, but if required anywhere then you can use the following code to specify the endpoint address using C# code:
// specify the same endpoint address that we got in the generated app.config file
EndpointAddress endPointAddress = new EndpointAddress("http://localhost:5000/WCFService/Sample/AreaService");
2. For providing the endpoint address explicitly, you can use the following code to initialize an instance of WCF client:
// initialize an instance of WCF client AreaClient areaclient = new AreaClient(new WSDualHttpBinding(), endPointAddress);
3. You can call the client operations by the following way:
double length = 85.5; double width = 35.5; Console.WriteLine(areaclient.AreaOfRectangle(length, width));
4. Alternatively you can also use the following code to access and use a WCF Client that requires no endpoint specification explicitly:
static void Main(string[] args)
{
// initialize an instance of WCF client
AreaClient areaclient = new AreaClient();
double length = 85.5;
double width = 35.5;
Console.WriteLine(areaclient.AreaOfRectangle(length, width));
}
For running the WCF client, ensure that the WCF service instance is already running. Otherwise run the WCF service instance and then run the WCF client instance to execute the specified client operation.

* will not be published
* hint: http://www.example.com