Exemple #1
0
        /// <summary>
        /// Gets the WSDL.
        /// </summary>
        /// <param name="config">
        /// The config.
        /// </param>
        private void GetWSDL(EndpointSettings config)
        {
            try
            {
                this._config = config;

                var resolver = new XmlProxyUrlResolver();
                resolver.SetConfig(config);

                var settings = new XmlReaderSettings {
                    IgnoreComments = true, IgnoreWhitespace = true, XmlResolver = resolver
                };
                string wsdlUrl = config.Wsdl;

                if (string.IsNullOrEmpty(wsdlUrl))
                {
                    wsdlUrl = string.Format(CultureInfo.InvariantCulture, "{0}?wsdl", config.EndPoint);
                }


                //nuova fabio
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(wsdlUrl);
                request.Timeout = 10 * 1000;//10 seconds
                this.SetupWebRequestAuth(request);

                using (System.Net.WebResponse response = request.GetResponse())
                    using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
                    {
                        this._wsdl = ServiceDescription.Read(reader);
                    }


                //using (XmlReader reader = XmlReader.Create(wsdlUrl, settings))
                //{
                //    this._wsdl = ServiceDescription.Read(reader);
                //}
            }
            catch (System.Exception ex) {
                System.Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Gets the WSDL.
        /// </summary>
        /// <param name="config">
        /// The config.
        /// </param>
        private void GetWSDL(EndpointSettings config)
        {
            try
            {
                var resolver = new XmlProxyUrlResolver();
                resolver.SetConfig(config);

                var settings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true, XmlResolver = resolver };
                string wsdlUrl = config.Wsdl;

                if (string.IsNullOrEmpty(wsdlUrl))
                {
                    wsdlUrl = string.Format(CultureInfo.InvariantCulture, "{0}?wsdl", config.EndPoint);
                }

                //System.Net.WebProxy myProxy = new System.Net.WebProxy();
                //myProxy.UseDefaultCredentials = true;
                //System.Uri newUri = new System.Uri("http://proxy.istat.it:3128");
                //myProxy.Address = newUri;

                System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                System.Net.WebRequest request = System.Net.WebRequest.Create(wsdlUrl);

                request.UseDefaultCredentials = true;

                var webProxy = System.Net.WebProxy.GetDefaultProxy();
                webProxy.UseDefaultCredentials = true;
                request.Proxy = webProxy;

                using (System.Net.WebResponse response = request.GetResponse())
                using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
                {
                    this._wsdl = ServiceDescription.Read(reader);
                }

                //using (XmlReader reader = XmlReader.Create(wsdlUrl, settings))
                //{
                //    this._wsdl = ServiceDescription.Read(reader);
                //}

            }
            catch(System.Exception ex) {
                System.Console.WriteLine(ex.Message);
            }
        }