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-questions-6th/p/itmdyuqzdqx8cvqx
- Awesome list of 12 great .NET and C# interview question videos from youtube http://www.youtube.com/watch?v=8iIvyNPwruU&list=PL5753E1DFB675A268
- Great quick revision videos on C# and .NET http://www.youtube.com/watch?v=gaDn-sVLj8Q
- Important WCF interview question around DataContractserializer and XML serializer http://www.dotnetinterviewquestions.in/article_wcf-interview-questions-with-answers-:-what-is-datacontractserializer-and-how-it%EF%BF%BDs-different-from-xmlserializer-_150.html
- 25 important WCF interview question list very important for quick revision http://www.questpond.com/dotnet/WCF-Interview-Questions-and-Answers.html