Difference between WCF Proxy and Channel FactoryPrint
There are two ways : Proxy and Channel Factory; to create a WCF Client or calling a WCF Service. In this article, I am going to expose the difference between Proxy and Channel Factory.
A WCF proxy is a CLR class that exposes the service contract. A Service proxy class has the service contract operations and some additional operations for managing the proxy life cycle and the connection to the service.
There are two ways to create a WCF proxy as given below:
Using Visual Studio by adding service reference to the client application.
Using SvcUtil.exe command-line utility.
A channel factory creates channels of different types that are used by client to send messages to the service. ChannelFactory class is used with a known interface to create the channel. This approach is commonly used when you have access control to both the server and the client.
WSHttpBinding binding = new WSHttpBinding(); EndpointAddress endpoint = new EndpointAddress("http://localhost/WcfService/MyService.svc/ws"); ChannelFactory<IMyService>channelFactory = new ChannelFactory<IMyService>(binding,endpoint ); IMyService channel = channelFactory.CreateChannel(); //calling service operation channel.DoWork(); //Close channel channelFactory.Close();
Difference between WCF Proxy and Channel Factory
What do you think?
I hope you will enjoy the tips while programming with WCF. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.