As a client that wants to communicate with the service, there are several ways to do so: 1. Use ChannelFactory<T> and call the service: ChannelFactory
IContractchannel = cf.CreateChannel();
As a client that wants to communicate with the service, there are several ways to do so:
1. Use ChannelFactory<T> and call the service:
ChannelFactory<IContract> cf =
2. Using svcutil tool that generates a typed proxy for you.
3. Implement a typed proxy that inherits from ClientBase<T>.
Here is a code sample of a generic proxy. This proxy also inherits from ClientBase<T>, but allows you not to created a specific class for each service. Additionaly I extended the class by overriding the CreateChannel method, where i added the credentials for the call.
/// Generic Proxy for service calls.
/// <typeparam name="T">The service Contract</typeparam>
public class GenericProxy<T> : ClientBase<T> where T : class
public GenericProxy(string endpoint)
/// When creating the channel, set the credentials
protected override T CreateChannel()
this.ChannelFactory.Credentials.UserName.UserName = "user";
this.ChannelFactory.Credentials.UserName.Password = "123456";
/// Returns the transparent proxy for the service call
public T Proxy
Using this class, your client code should look similar to this:
using( GenericProxy<IContract> service =