There are two ways of consuming WCF service one by using add reference and other by using channel factory.
- Add service reference and generate proxy
FirstServiceClient c = newFirstServiceClient(); Console.WriteLine(c.GetData3()); Console.ReadKey();
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.
- Nice site for c# and .NET trainings http://www.sukesh-marla.com/
- More than 10,000 .NET and C# interview question www.dotnetinterviewquestions.in
- NET interview question book by bpb publications http://www.flipkart.com/net-interview-qu
- Awesome list of 12 great .NET and C# interview question videos from youtube http://www.youtube.com/watch?v=8iIvyNPwr
- Great quick revision videos on C# and .NET http://www.youtube.com/watch?v=gaDn-sVLj
- Important WCF interview question around DataContractserializer and XML serializer http://www.dotnetinterviewquestions.in/a
rticle_wcf-interview-questions-with-answ ers-:-what-is-datacontractserializer-and-h ow-it%EF%BF%BDs-different-from-xmlserial izer-_150.html
- 25 important WCF interview question list very important for quick revision http://www.questpond.com/dotnet/WCF-Inte