Saturday 10 August 2013

WCF - Invoke a WCF Service Application from a client

     First step to invoke a WCF service get the proxy class for that using  svcutil command in vscmd.exe
In our example let we take following example to Create WCF Service and Host WCF Service

    Type the following cmd in visual studio command prompt to download the proxy class
svcutile.exe  "WCF Hosted service url" , Results in generate a two files.
Service.cs and config file



Call a WCF service

Step 1. Right click the project.
Step 2. Add a Service Reference and Enter the Url.
Step 3. Select ok.


ServiceReference1.Service1Client cli = new ServiceReference1.Service1Client();
string h=cli.WelcomeMessage("rajesh");
Console.WriteLine(h);


All the class are ends with Client ,create a object and invoke the methods 

output:



From this article you can learn how to call a WCF service from a client.