public ICoreService2010 GetNewClient() { if (_Factory != null) { return(_Factory); } if (_Config.AppSettings.Settings.Count == 0) { throw new ArgumentException("Config file not found. Pelase set property to 'Copy Always' and confirm name."); } string hostname = GetAppSetting("hostname"); string username = GetAppSetting("impersonation_user"); string password = GetAppSetting("impersonation_password"); var binding = new BasicHttpBinding() { MaxBufferSize = 4194304, // 4MB MaxBufferPoolSize = 4194304, MaxReceivedMessageSize = 4194304, ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxStringContentLength = 4194304, // 4MB MaxArrayLength = 4194304, }, Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.TransportCredentialOnly, Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Windows } } }; hostname = string.Format("{0}{1}{2}", hostname.StartsWith("http") ? "" : "http://", hostname, hostname.EndsWith("/") ? "" : "/"); var endpoint = new EndpointAddress(hostname + "/webservices/CoreService.svc/basicHttp_2010"); ChannelFactory <ICoreService2010> factory = new ChannelFactory <ICoreService2010>(binding, endpoint); factory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(username, password); _Factory = factory.CreateChannel(); return(_Factory); }
public ICoreService2010 GetNewClient() { if (_Factory != null) return _Factory; if (_Config.AppSettings.Settings.Count == 0) throw new ArgumentException("Config file not found. Please set property to 'Copy Always' and confirm name."); string hostname = _Config.AppSettings.Settings["hostname"].Value; string username = _Config.AppSettings.Settings["impersonation_user"].Value; string password = _Config.AppSettings.Settings["impersonation_password"].Value; var binding = new BasicHttpBinding() { MaxBufferSize = 4194304, // 4MB MaxBufferPoolSize = 4194304, MaxReceivedMessageSize = 4194304, ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxStringContentLength = 4194304, // 4MB MaxArrayLength = 4194304, }, Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.TransportCredentialOnly, Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Windows } } }; hostname = string.Format("{0}{1}{2}", hostname.StartsWith("http") ? "" : "http://", hostname, hostname.EndsWith("/") ? "" : "/"); var endpoint = new EndpointAddress(hostname + "/webservices/CoreService.svc/basicHttp_2010"); ChannelFactory<ICoreService2010> factory = new ChannelFactory<ICoreService2010>(binding, endpoint); factory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(username, password); _Factory = factory.CreateChannel(); return _Factory; }
/// <summary> /// Initializes the core service client. /// </summary> private void InitializeCoreServiceClient() { _Tcmclient = GetNewClient(); }