A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.(From wiki). In case of WCF, proxy class helps client application to use WCF service,without knowing the address or implementation details. Here is the code for generic WCF proxy, using ChannelFactory class. ChannelFactory enables you to dynamically creating a proxy object based on the Service Contract. It will help you to avoid update service references or proxies generated using svcutil utility.
The IDisposable implementation will help developers to close / abort channel with “using” statement.
And you can use this like the following.
The code is invoking Add method of Calculator service. The EndPoint and Binding information will fetched from the app.config file.
Happy Programming :)
What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.