<pre> WSHttpBinding httpBinding = new WSHttpBinding(); httpBinding.Name = "WSHttpBinding_IService"; httpBinding.CloseTimeout = TimeSpan.MaxValue; httpBinding.OpenTimeout = TimeSpan.MaxValue; httpBinding.ReceiveTimeout = TimeSpan.MaxValue; httpBinding.SendTimeout = TimeSpan.MaxValue; httpBinding.BypassProxyOnLocal = false; httpBinding.TransactionFlow = false; httpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; httpBinding.MaxBufferPoolSize = Convert.ToInt64("2147483646"); httpBinding.MaxReceivedMessageSize = Convert.ToInt64("2147483646"); httpBinding.MessageEncoding = WSMessageEncoding.Mtom; httpBinding.TextEncoding = Encoding.UTF8; httpBinding.UseDefaultWebProxy = true; httpBinding.AllowCookies = false; httpBinding.ReliableSession.Ordered = true; httpBinding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue; httpBinding.ReliableSession.Enabled = false; if (ServerURL.ToLower().Contains("https://")) httpBinding.Security.Mode = SecurityMode.Transport; else httpBinding.Security.Mode = SecurityMode.Message; httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; httpBinding.Security.Transport.Realm = ""; httpBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; httpBinding.Security.Message.NegotiateServiceCredential = true; httpBinding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; EndpointAddress endpoint = new EndpointAddress(new Uri(ServerURL + "/Service/MyService.svc"), EndpointIdentity.CreateDnsIdentity("localhost")); ServiceClient _serviceClient = new ServiceClient (httpBinding, endpoint); _serviceClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; _serviceClient.ClientCredentials.Windows.ClientCredential.Domain = DomainName; _serviceClient.ClientCredentials.Windows.ClientCredential.UserName = UserName; _serviceClient.ClientCredentials.Windows.ClientCredential.Password = Password; _serviceClient.Open(); string CnfgRbInstalled = _serviceClient.GetAccessToken(); _serviceClient.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)