Wednesday, October 17, 2012

WCF : Binding: General method to create service client


public static TClient GetServiceClient(string url) 
            where TClient : class
            where TInterface:class
        {
            var binding = new BasicHttpBinding { MaxReceivedMessageSize = 50000000 }; //50 MB
            var endPoint = new EndpointAddress(url);
         
            var result = Activator.CreateInstance(typeof(TClient), binding, endPoint) as TClient;
            var client = result as ClientBase;

           //AttachSecurityInfo(binding, client.ChannelFactory.Credentials);
            return result;
        }




No comments:

Post a Comment