This is a good starting point, move the binding and endpoint information from the configuration file to your class:
protected BasicHttpBinding binding = new BasicHttpBinding() { Name = "Name your binding here", CloseTimeout = new TimeSpan(0, 1, 0), OpenTimeout = new TimeSpan(0, 1, 0), ReceiveTimeout = new TimeSpan(0, 10, 0), SendTimeout = new TimeSpan(0, 1, 0), AllowCookies = false, BypassProxyOnLocal = false, HostNameComparisonMode = HostNameComparisonMode.StrongWildcard, MaxBufferSize = 65536, MaxBufferPoolSize = 524288, MaxReceivedMessageSize = 65536, MessageEncoding = WSMessageEncoding.Text, TransferMode = TransferMode.Buffered, UseDefaultWebProxy = true, Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.Transport, Message = new BasicHttpMessageSecurity() { AlgorithmSuite = SecurityAlgorithmSuite.Default, ClientCredentialType = BasicHttpMessageCredentialType.UserName}, Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Digest } }, }; protected EndpointAddress endPoint = new EndpointAddress("http://localhost:55314/MyService.svc");
and then
MyServiceClient client = new MyServiceClient(binding, endpont);
Try this and customize the binding to your needs, especially Security.
source share