Proxy in WCF


This blog describes what is proxy in WCF and how to generate it. a proxy is not but a CLR class that exposes single CLR interface that represents the service contract provided by WCF Service. It provides same operations what WCF service provides, but we can also add some extra method or fields to this class to manage proxy life cycle and connection.

The proxy completely encapsulates every aspect of the service, its implementation technology, endpoints(Address, Binding, Contract) and runtime platform.

How to generate

There are two ways to generate proxy by Visual Studio and command line. In Visual Studio we can generate proxy by using option AddServiceReference. In AddserviceReference dialog box we need to supply information about service like address of the service and the namespace to contain the proxy.

In command line we need to use SvcUtil.exe command line utility. We need to provide SvcUtil with address or the metadata exchange endoint address. Optionally we can provide proxy filename and file path. The default filename of proxy is output.cs but we can also use the /out switch to indicate a different name.


SvcUtil.exe http//hostname:port/servicename/out:proxy name.cs
Ebook Download
View all
View all