What are the different ways to generate proxy in WCF? | WCF Interview Question

, ,
Generating proxy using Visual Studio is simple and straight forward.
  • Right click References and choose “Add Service Reference”.
  • Provide base address of the service on “Add Service Reference” dialog box and click “Go” button. Service will be listed below.
  • Provide namespace and click OK.
Visual studio will generate a proxy automatically.
We can generate proxy using svcutil.exe utility using command line. This utility requires few parameters like HTTP-GET address or the metadata exchange endpoint address and a proxy filename i.e. optional.
svcutil http://localhost/MyService/Service1.svc /out:MyServiceProxy.cs
If we are hosting the service at a different port(other than default for IIS which is 80), we need to provide port number in base address.
svcutil http://localhost:8080/MyService/Service1.svc /out:MyServiceProxy.cs