?

Log in

Previous Entry | Next Entry

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();
Console.WriteLine(c.GetData3());
   Console.ReadKey();


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

When to use what?

ChannelFactory

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

Advantage


  • 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)

Disadvantages

  • More client side work.

Proxy

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

Advantages


  • 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.

Disadvantages


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

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



Other References:-
Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

January 2017
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Tags

Powered by LiveJournal.com