I've created some WCF service on my server, now I've to implement the client side, and I've basically two way of doing it:
With ClientBase implementation
public class SampleServiceClient : ClientBase<ISampleService>, ISampleService
{
public SampleServiceClient(Binding binding, EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public string SampleMethod(string msg)
{
return base.Channel.SampleMethod(msg);
}
}
With ChannelFactory
public ISampleService GetService(Binding binding, EndpointAddress remoteAddress){
ChannelFactory<ISampleService> channelFactory = new ChannelFactory<ISampleService>(binding, address);
return channelFactory.CreateChannel();
}
What is the advantage of one over the other? Is there some additional functionality in the ClientBase
? Is there a best practice?