Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="session">The session to use for all communication with the webservice.
        /// The user name and password are used from their to provide such details to the
        /// webservice with each call without exposing such detail to the user of the
        /// library.</param>
        public Request(Session session)
        {
            this.session = session;

            BasicHttpBinding binding;

            if (this.session.NetworkCredential != null)
            {
                binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            }
            else
            {
                binding = new BasicHttpBinding();
            }

            if (this.session.Url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            {
                binding.Security.Mode = BasicHttpSecurityMode.Transport;
                binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
            }

            var endpoint = new EndpointAddress(this.session.Url);

            this.mc = new MantisConnectWebservice.MantisConnectPortTypeClient(binding, endpoint);

            if (this.session.NetworkCredential != null)
            {
                this.mc.ClientCredentials.UserName.UserName = this.session.NetworkCredential.UserName;
                this.mc.ClientCredentials.UserName.Password = this.session.NetworkCredential.Password;
            }
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="session">The session to use for all communication with the webservice.
        /// The user name and password are used from their to provide such details to the
        /// webservice with each call without exposing such detail to the user of the 
        /// library.</param>
        public Request(Session session)
        {
            this.session = session;

            BasicHttpBinding binding;

            if (this.session.NetworkCredential != null)
            {
                binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            }
            else
            {
                binding = new BasicHttpBinding();
            }

            if (this.session.Url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
            {
                binding.Security.Mode = BasicHttpSecurityMode.Transport;
                binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
            }

            var endpoint = new EndpointAddress(this.session.Url);
            this.mc = new MantisConnectWebservice.MantisConnectPortTypeClient(binding, endpoint);

            if (this.session.NetworkCredential != null)
            {
                this.mc.ClientCredentials.UserName.UserName = this.session.NetworkCredential.UserName;
                this.mc.ClientCredentials.UserName.Password = this.session.NetworkCredential.Password;
            }
        }