/// <summary> /// Initializes a new instance of <see cref="CritSendConnect"/> /// </summary> /// <param name="fast">If set to <c>true</c> use the fast web service.</param> /// <param name="user">The Critsent user to use instead of the configuration file.</param> /// <param name="key">The password to use instead of the configuration file.</param> public CritSendConnect(bool fast, string user, string key) { _fast = fast; _configuration = ConnectorConfiguration.Instance; _user = user ?? _configuration.User; _key = key ?? _configuration.Key; // This line avoids the HTTP 417 errors. // Found at http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5023d48b-476a-47db-b108-1a4eca6a5316 System.Net.ServicePointManager.Expect100Continue = false; WSDL01forMxMaster client = CreateClient(!_fast ? _configuration.Hosts : _configuration.FastHosts) ?? GetFallbackHost(_configuration.Hosts); _client = client; }
/// <summary> /// Creates a web service client instance. /// </summary> /// <param name="host"></param> /// <returns></returns> private WSDL01forMxMaster CreateClient(string host) { WSDL01forMxMaster client; try { client = new WSDL01forMxMaster { EnableDecompression = true, Url = host + Wsdl }; // If the url does not work an exception is thrown. var auth = GetAuthentication(); client.isTag(auth, "test"); } catch (Exception) { return null; } return client; }