Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A

What are the various ways of consuming WCF services?(WCF C# interview questions with answers)

There are two ways of consuming WCF service one by using add reference and other by using channel factory.

  1. Add service reference and generate proxy

WCF services

   FirstServiceClient c =   newFirstServiceClient();

2.  We can use ChannelFactory
ChannelFactory<IFirstService> c = newChannelFactory<IFirstService>("b1");
IFirstService f = c.CreateChannel();

When to use what?


When you have access to both service and client use channel factory. Because

  • In case channel factory, you need to explicitly define client endpoints.

  • You need to have direct access to service contract interface


  • Every time when we make some changes into service contract , it’s not required to update reference at client side (because there is no reference)


  • More client side work.


When you won’t have control over the service use proxies


  • Less client side work.

  • When we generate proxy, Visual studio does everything for us. It not only generates proxy service classes but also generates client endpoints.


  • Every time you make changes into service contract you have to update service reference.

Below is a great WCF video created by which discusses one more important WCF interview question which talks about canmethod overloading be done in WCF.

Other References:-
Tags: .net interview questions, c# interview questions, csharp interview questions, it interview questions with answers, programming iterview questions, wcf channelfactory interview questions, wcf fresher interview questions, wcf interview questions, wcf(windows communication foundation)

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded