internal virtual T WithProxy <T>(IKernel kernel, Func <GetDataSoap, T> client)
        {
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            Uri uri = GetWebServiceUri(kernel);

            HttpBindingBase binding = CreateBinding($"PerfionService.{GetType().Name}", uri, kernel);

            ConfigureBinding(binding, kernel);

            GetDataSoapClient proxy = new GetDataSoapClient(binding, new EndpointAddress(uri));

            ConfigureClientCredentials(proxy.ClientCredentials, kernel);

            try
            {
                return(client(proxy));
            }
            finally
            {
                try
                {
                    proxy.Close();
                }
                catch
                {
                    proxy.Abort();
                    throw;
                }
            }
        }
Esempio n. 2
0
        protected override void OnApplyConfiguration(Binding binding)
        {
            HttpBindingBase httpBindingBase = (HttpBindingBase)binding;

            httpBindingBase.BypassProxyOnLocal     = this.BypassProxyOnLocal;
            httpBindingBase.HostNameComparisonMode = this.HostNameComparisonMode;
            httpBindingBase.MaxBufferPoolSize      = this.MaxBufferPoolSize;
            httpBindingBase.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            httpBindingBase.TextEncoding           = this.TextEncoding;
            httpBindingBase.TransferMode           = this.TransferMode;
            httpBindingBase.UseDefaultWebProxy     = this.UseDefaultWebProxy;
            httpBindingBase.AllowCookies           = this.AllowCookies;
            if (this.ProxyAddress != null)
            {
                httpBindingBase.ProxyAddress = this.ProxyAddress;
            }

            PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;

            if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
            {
                httpBindingBase.MaxBufferSize = this.MaxBufferSize;
            }

            this.ReaderQuotas.ApplyConfiguration(httpBindingBase.ReaderQuotas);
        }
        protected internal override void ConfigureBinding(HttpBindingBase binding, IKernel kernel)
        {
            if (_connection != null)
            {
                _connection.ConfigureBinding(binding, kernel);
                return;
            }

            base.ConfigureBinding(binding, kernel);
        }
        public static void SetConfigValuesMax(string address, string endpointName)
        {
            if (string.IsNullOrEmpty(address))
            {
                throw new ArgumentException("Bad config  file value => endpoint address");
            }
            if (string.IsNullOrEmpty(endpointName))
            {
                throw new ArgumentException("Bad config  file value => endpoint name");
            }

            var time = new TimeSpan(0, 1, 0);

            if (Address == null)
            {
                Address = new EndpointAddress(address);
            }
            if (Binding == null)
            {
                Binding = new BasicHttpsBinding
                {
                    TransferMode = TransferMode.Streamed,
                    Security     = new BasicHttpsSecurity
                    {
                        Mode      = BasicHttpsSecurityMode.Transport,
                        Transport = new HttpTransportSecurity
                        {
                            ClientCredentialType = HttpClientCredentialType.None,
                        }
                    },

                    Name = endpointName,
                    MaxReceivedMessageSize = 2147483647,
                    AllowCookies           = true,
                    MaxBufferSize          = 2147483647,
                    MaxBufferPoolSize      = 524288,
                    ReaderQuotas           = new XmlDictionaryReaderQuotas
                    {
                        MaxArrayLength         = 2147483647,
                        MaxDepth               = 32,
                        MaxStringContentLength = 2147483647,
                        MaxBytesPerRead        = 2147483647,
                        MaxNameTableCharCount  = 2147483647
                    },
                    CloseTimeout   = time,
                    OpenTimeout    = time,
                    ReceiveTimeout = time,
                    SendTimeout    = time
                }
            }
            ;
        }
    }
        protected internal virtual void ConfigureBinding(HttpBindingBase binding, IKernel kernel)
        {
            if (binding == null)
            {
                throw new ArgumentNullException(nameof(binding));
            }
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.ReceiveTimeout         = binding.SendTimeout = TimeSpan.MaxValue;
        }
Esempio n. 6
0
    public static void Configure(HttpBindingBase binding)
    {
        if (binding == null)
        {
            throw new ArgumentException("Argument 'binding' cannot be null. Cannot configure binding.");
        }

        binding.SendTimeout                         = new TimeSpan(0, 0, 30, 0); // 30 minute timeout
        binding.MaxBufferSize                       = Int32.MaxValue;
        binding.MaxBufferPoolSize                   = 2147483647;
        binding.MaxReceivedMessageSize              = Int32.MaxValue;
        binding.ReaderQuotas.MaxArrayLength         = Int32.MaxValue;
        binding.ReaderQuotas.MaxBytesPerRead        = Int32.MaxValue;
        binding.ReaderQuotas.MaxDepth               = Int32.MaxValue;
        binding.ReaderQuotas.MaxNameTableCharCount  = Int32.MaxValue;
        binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
    }
Esempio n. 7
0
        protected override void OnApplyConfiguration(Binding binding)
        {
            HttpBindingBase basicHttpBinding = (HttpBindingBase)binding;

            basicHttpBinding.AllowCookies           = AllowCookies;
            basicHttpBinding.BypassProxyOnLocal     = BypassProxyOnLocal;
            basicHttpBinding.HostNameComparisonMode = HostNameComparisonMode;
            basicHttpBinding.MaxBufferPoolSize      = MaxBufferPoolSize;
            basicHttpBinding.MaxBufferSize          = MaxBufferSize;
            basicHttpBinding.MaxReceivedMessageSize = MaxReceivedMessageSize;
            basicHttpBinding.ProxyAddress           = ProxyAddress;

            ReaderQuotas.ApplyConfiguration(basicHttpBinding.ReaderQuotas);

            basicHttpBinding.TextEncoding       = TextEncoding;
            basicHttpBinding.TransferMode       = TransferMode;
            basicHttpBinding.UseDefaultWebProxy = UseDefaultWebProxy;
        }
Esempio n. 8
0
        protected internal override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding);
            HttpBindingBase httpBindingBase = (HttpBindingBase)binding;

            this.InitializeAllowCookies(httpBindingBase);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.BypassProxyOnLocal, httpBindingBase.BypassProxyOnLocal);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, httpBindingBase.HostNameComparisonMode);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, httpBindingBase.MaxBufferSize);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferPoolSize, httpBindingBase.MaxBufferPoolSize);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReceivedMessageSize, httpBindingBase.MaxReceivedMessageSize);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyAddress, httpBindingBase.ProxyAddress);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TextEncoding, httpBindingBase.TextEncoding);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, httpBindingBase.TransferMode);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.UseDefaultWebProxy, httpBindingBase.UseDefaultWebProxy);

            this.ReaderQuotas.InitializeFrom(httpBindingBase.ReaderQuotas);
        }
Esempio n. 9
0
        protected internal override void InitializeFrom(Binding binding)
        {
            HttpBindingBase b = (HttpBindingBase)binding;

            base.InitializeFrom(binding);
            AllowCookies           = b.AllowCookies;
            BypassProxyOnLocal     = b.BypassProxyOnLocal;
            HostNameComparisonMode = b.HostNameComparisonMode;
            MaxBufferPoolSize      = b.MaxBufferPoolSize;
            MaxBufferSize          = b.MaxBufferSize;
            MaxReceivedMessageSize = b.MaxReceivedMessageSize;
            ProxyAddress           = b.ProxyAddress;

            ReaderQuotas.ApplyConfiguration(b.ReaderQuotas);

            TextEncoding       = b.TextEncoding;
            TransferMode       = b.TransferMode;
            UseDefaultWebProxy = b.UseDefaultWebProxy;
        }
Esempio n. 10
0
        private void Init()
        {
            Trace.TraceInformation($"Init: " + _url);
            var uri = new Uri(_url);

            HttpBindingBase binding = uri.Scheme == Uri.UriSchemeHttps ? new BasicHttpsBinding()
            {
                MaxReceivedMessageSize = 1073741824
            } as HttpBindingBase : new BasicHttpBinding()
            {
                MaxReceivedMessageSize = 1073741824
            };

            using (var service = new DownloadServiceClient(binding, new EndpointAddress(uri)))
            {
                AllInfoObject = service.GetAllDownloadFileInfo();
                InfoObject    = service.GetLastDownloadFileInfo();
                _init         = true;
            }
        }
Esempio n. 11
0
        public static void Configure(HttpBindingBase binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            //binding.BypassProxyOnLocal = true;
            binding.OpenTimeout    = new TimeSpan(0, 0, 10, 0); // 30 minute timeout
            binding.SendTimeout    = new TimeSpan(0, 0, 10, 0); // 30 minute timeout
            binding.ReceiveTimeout = new TimeSpan(0, 0, 10, 0); // 30 minute timeout
            binding.CloseTimeout   = new TimeSpan(0, 0, 10, 0); // 30 minute timeout

            binding.MaxBufferSize                       = Int32.MaxValue;
            binding.MaxBufferPoolSize                   = 2147483647;
            binding.MaxReceivedMessageSize              = Int32.MaxValue;
            binding.ReaderQuotas.MaxArrayLength         = Int32.MaxValue;
            binding.ReaderQuotas.MaxBytesPerRead        = Int32.MaxValue;
            binding.ReaderQuotas.MaxDepth               = Int32.MaxValue;
            binding.ReaderQuotas.MaxNameTableCharCount  = Int32.MaxValue;
            binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
        }
 internal override void InitializeAllowCookies(HttpBindingBase binding)
 {
     // do not emit allowCookies=true in generated config because BasicHttpContextBinding will always set AllowCookies to true anyway
 }
Esempio n. 13
0
 // BasicHttpContextBinding uses this hook to not emit AllowCookies
 internal virtual void InitializeAllowCookies(HttpBindingBase binding)
 {
     SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AllowCookies, binding.AllowCookies);
 }
Esempio n. 14
0
 protected override void ConfigureBinding(HttpBindingBase binding, IKernel kernel)
 {
     base.ConfigureBinding(binding, kernel);
 }
 internal override void InitializeAllowCookies(HttpBindingBase binding)
 {
     // do not emit allowCookies=true in generated config because BasicHttpContextBinding will always set AllowCookies to true anyway
 }