public Spira_ImportExport(string server, string user, string password) { //Assign internal vars.. this._server = server; this._user = user; this._password = password; this._client = Business.StaticFuncs.CreateClient(this._server); //Hook up events. this._client.Connection_Authenticate2Completed += new EventHandler <SpiraTeam_Client.Connection_Authenticate2CompletedEventArgs>(_client_Connection_Authenticate2Completed); }
/// <summary>Creates a web client for use.</summary> /// <param name="serverAddress">The base address of the server.</param> /// <returns>ImportExportClient</returns> public static SoapServiceClient CreateClient(string serverAddress) { SoapServiceClient retClient = null; try { //The endpoint address. EndpointAddress EndPtAddr = new EndpointAddress(new Uri(serverAddress + Settings.Default.app_ServiceURI)); //Create the soap client. BasicHttpBinding wsDualHttp = new BasicHttpBinding(); wsDualHttp.CloseTimeout = TimeSpan.FromMinutes(1); wsDualHttp.OpenTimeout = TimeSpan.FromMinutes(1); wsDualHttp.ReceiveTimeout = TimeSpan.FromMinutes(1); wsDualHttp.SendTimeout = TimeSpan.FromMinutes(1); wsDualHttp.BypassProxyOnLocal = false; wsDualHttp.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; wsDualHttp.MaxBufferPoolSize = Int32.MaxValue; wsDualHttp.MaxReceivedMessageSize = Int32.MaxValue; wsDualHttp.MessageEncoding = WSMessageEncoding.Text; wsDualHttp.TextEncoding = Encoding.UTF8; wsDualHttp.UseDefaultWebProxy = true; wsDualHttp.ReaderQuotas.MaxDepth = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxArrayLength = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue; wsDualHttp.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue; wsDualHttp.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate; wsDualHttp.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; wsDualHttp.Security.Mode = BasicHttpSecurityMode.None; wsDualHttp.AllowCookies = true; wsDualHttp.TransferMode = TransferMode.Streamed; //Configure for alternative connection types. if (EndPtAddr.Uri.Scheme == "https") { wsDualHttp.Security.Mode = BasicHttpSecurityMode.Transport; wsDualHttp.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; //Allow self-signed certificates Inflectra.SpiraTest.IDEIntegration.VisualStudio2012.Business.Spira_ImportExport.PermissiveCertificatePolicy.Enact(""); } retClient = new SpiraTeam_Client.SoapServiceClient(wsDualHttp, EndPtAddr); } catch (Exception ex) { Logger.LogMessage(ex); retClient = null; } return(retClient); }
/// <summary>Called when we're finished with the client. Verifies that the client is disconnected.</summary> void IDisposable.Dispose() { if (this._client != null) { try { this._client.Connection_Disconnect(); } catch { } finally { this._client = null; } } }