Whoever comes from a soap service background always may have an assumption that for generating proxies you need to rely on svcutil.exe.If you think so,this assumption is wrong.You can create a proxy manually too.I am explaining here how you can do for a WCF service.
The proxy class derives from the class ClientBase<T> & ClientBase<T> accepts a single generic type parameter which is the service contract this proxy encapsulates. Say you have a servicecontract IVendorServices,then ClientBase<T> gets replaced with ClientBase<IVendorServices>.
[ServiceContract] public interface IVendorServices { [WebGet(UriTemplate = "v1/Ping")] [OperationContract] string Ping(); } public class VendorServices : IVendorServices { [Description("Service for Testing")] public string Ping() { return DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss:fffffffK"); } } public class VendorProxy : ClientBase<IVendorServices>, IVendorServices { public VendorProxy() { } #region IVendorServices Members public string Ping() { return Channel.Ping(); } #endregion }
After you write the proxy class,if you place mouse over the interface name,it will create the members of class automatically.The Channel property of ClientBase<T> is of the type of T parameter passed & if you write Channel.Ping(),it delegates the call to the method’s actual implementation & returns you the result.
Hope you got some idea on how it works 🙂
Channel is of type IVendorServices .Where is the concrete class for this interface ? Is it also created dynamically?
I did not understand what you have meant by dynamically here.VendorServices class implements methods of IVendorServices..Ya Channel is of type IVendorServices for that proxy.