public MzkTechnicalInspectionClient ConnectAsync(string userName, string password, IEventAggregator eventAggregator, string domain = "lfmd") { try { _eventAggregator = eventAggregator; BasicHttpBinding basicHttpBinding = new BasicHttpBinding() { MaxBufferPoolSize = int.MaxValue, MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue, OpenTimeout = new TimeSpan(2, 0, 0), ReceiveTimeout = new TimeSpan(2, 0, 0), SendTimeout = new TimeSpan(2, 0, 0), AllowCookies = true, }; basicHttpBinding.ReaderQuotas.MaxDepth = int.MaxValue; basicHttpBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue; basicHttpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue; basicHttpBinding.ReaderQuotas.MaxBytesPerRead = int.MaxValue; basicHttpBinding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue; basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;//http://srfmlaxtest01/MicrosoftDynamicsAXAif60/TechnicalInspection/xppservice.svc http://srfmlaxtest01/MicrosoftDynamicsAXAif60/TechnicalInspection/xppservice.svc client = new MzkTechnicalInspectionClient(basicHttpBinding, new EndpointAddress("http://srfmlbispstg01.lfmd.co.za/MicrosoftDynamicsAXAif60/TechnicalInspection/xppservice.svc")); client.ClientCredentials.UserName.UserName = domain + "\"" + userName; client.ClientCredentials.UserName.Password = password; client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(userName, password, domain); return(client); } catch (Exception ex) { return(client); } }
public MzkTechnicalInspectionClient GetServiceClient() { try { BasicHttpBinding basicHttpBinding = new BasicHttpBinding() { MaxBufferPoolSize = int.MaxValue, MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue, OpenTimeout = new TimeSpan(2, 0, 0), ReceiveTimeout = new TimeSpan(2, 0, 0), SendTimeout = new TimeSpan(2, 0, 0), AllowCookies = true }; basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;//http://srfmlaxtest01/MicrosoftDynamicsAXAif60/TechnicalInspection/xppservice.svc _client = new MzkTechnicalInspectionClient(basicHttpBinding, new EndpointAddress("http://srfmlbispstg01.lfmd.co.za/MicrosoftDynamicsAXAif60/TechnicalInspection/xppservice.svc")); _client.ClientCredentials.UserName.UserName = "******" + "\"" + "erpsetup"; _client.ClientCredentials.UserName.Password = "******"; _client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification; _client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("erpsetup", "AXrocks100", "lfmd"); } catch (Exception) { throw; } return(_client); }