Exemple #1
0
 protected SyncOp(string name, int timeout, model.IProxy proxy, ILog log)
 {
     Log          = log;
     Name         = name;
     Proxy        = proxy;
     TimeoutInSec = timeout;
 }
Exemple #2
0
        //TODO: FB client.GetMetadata is not working working on linux, instead use DiscoveryClientProtocol.
        //this means that mex bindings are currently not supported on linux
        void DownloadWeb(model.IProxy proxy, out List <wsdlDescription.ServiceDescription> descriptions, out List <XmlSchema> schemas)
        {
            DiscoveryClientProtocol client = new DiscoveryClientProtocol();

            if (proxy.ProxyType == model.Proxy.EProxyType.Enabled)
            {
                client.Proxy             = new System.Net.WebProxy(proxy.Host, proxy.Port);
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            }

            descriptions = new List <wsdlDescription.ServiceDescription>();
            schemas      = new List <XmlSchema>();

            //download document
            client.AllowAutoRedirect = true;
            client.Timeout           = _timeoutInSeconds * 1000;

            client.Documents.Clear();
            client.DiscoverAny(_wsdlEndpoint);
            client.ResolveAll();

            //generate stub
            foreach (var v in client.Documents.Values)
            {
                if (v is wsdlDescription.ServiceDescription)
                {
                    descriptions.Add((wsdlDescription.ServiceDescription)v);
                }
                else if (v is XmlSchema)
                {
                    schemas.Add((XmlSchema)v);
                }
            }
        }
Exemple #3
0
        //System wide proxy settings are not implemented for linux, instead proxy settings must be explicitly set.
        public static WebProxy GetWebProxy(model.IProxy proxy)
        {
            WebProxy webProxy;

            switch (proxy.ProxyType)
            {
            case model.Proxy.EProxyType.Disabled:

                return(null);

            case model.Proxy.EProxyType.Enabled:

                webProxy             = new WebProxy(proxy.Host, proxy.Port);
                webProxy.Credentials = CredentialCache.DefaultCredentials;
                return(webProxy);

            case model.Proxy.EProxyType.System:

#if __MonoCS__
                return(new WebProxy());
#else
                //Bug fix: WebRequest.GetSystemWebProxy throws a null reference exception on Windows 7 x64.
                //WebRequest.DefaultWebProxy uses a proxy if set in the web.config otherwise uses the system wide proxy settings from IE
                webProxy             = ConvertToWebProxy(WebRequest.DefaultWebProxy);
                webProxy.Credentials = CredentialCache.DefaultCredentials;
                return(webProxy);
#endif
            default:

                return(null);
            }
        }
Exemple #4
0
        protected AsyncOp(string name, int timeout, model.IProxy proxy, ILog log)
        {
            Log          = log;
            Name         = name;
            Proxy        = proxy;
            TimeoutInSec = timeout;

            _timeoutObject            = new TimeoutObject(Name, timeout);
            _timeoutObject.OnTimeout += _timeoutObject_OnTimeout;
        }
Exemple #5
0
        //returns true if service descriptions are retrieved
        //returns false if 0 service descriptions found, this signifies that the end point is not a web service description
        internal bool Download(model.IProxy proxy, out List <wsdlDescription.ServiceDescription> descriptions, out List <XmlSchema> schemas)
        {
            descriptions = new List <wsdlDescription.ServiceDescription>();
            schemas      = new List <XmlSchema>();

            if (_wsdlEndpoint.StartsWith("file"))
            {
                DownloadFile(out descriptions, out schemas);
            }
            else
            {
                DownloadWeb(proxy, out descriptions, out schemas);
            }

            return(descriptions.Count > 0);
        }
Exemple #6
0
        public static BasicHttpBinding GetWsdlBinding(model.IProxy proxy)
        {
            BasicHttpBinding binding = new BasicHttpBinding();

            if (proxy.ProxyType == model.Proxy.EProxyType.System)
            {
                binding.UseDefaultWebProxy = true;
            }
            else
            {
                WebProxy webProxy = ProxyWrapper.GetWebProxy(proxy);

                binding.UseDefaultWebProxy = false;
                if (proxy.ProxyType == model.Proxy.EProxyType.Enabled)
                {
                    binding.ProxyAddress = webProxy.Address;
                }
            }

            return(binding);
        }
Exemple #7
0
        void DownloadWeb(model.IProxy proxy, out List <wsdlDescription.ServiceDescription> descriptions, out List <XmlSchema> schemas)
        {
            descriptions = new List <wsdlDescription.ServiceDescription>();
            schemas      = new List <XmlSchema>();

            MetadataExchangeClient     client;
            MetadataExchangeClientMode exchangeMode;

            if (_wsdlEndpoint.EndsWith("mex"))
            {
                WSHttpBinding mexBinding = utils.BindingWrapper.GetMexBinding(proxy);

                client       = new MetadataExchangeClient(mexBinding);
                exchangeMode = MetadataExchangeClientMode.MetadataExchange;
            }
            else
            {
                BasicHttpBinding wsdlBinding = utils.BindingWrapper.GetWsdlBinding(proxy);

                client       = new MetadataExchangeClient(wsdlBinding);
                exchangeMode = MetadataExchangeClientMode.HttpGet;
            }

            client.ResolveMetadataReferences = true;
            client.OperationTimeout          = new TimeSpan(0, 0, _timeoutInSeconds);

            MetadataSet metadata = client.GetMetadata(new Uri(_wsdlEndpoint), exchangeMode);

            foreach (var metaDataSection in metadata.MetadataSections)
            {
                if (metaDataSection.Metadata is wsdlDescription.ServiceDescription)
                {
                    descriptions.Add((wsdlDescription.ServiceDescription)metaDataSection.Metadata);
                }
                else if (metaDataSection.Metadata is XmlSchema)
                {
                    schemas.Add((XmlSchema)metaDataSection.Metadata);
                }
            }
        }
Exemple #8
0
        public static WSHttpBinding GetMexBinding(model.IProxy proxy)
        {
            WSHttpBinding binding = new WSHttpBinding();

            binding.Security.Mode = SecurityMode.None;

            if (proxy.ProxyType == model.Proxy.EProxyType.System)
            {
                binding.UseDefaultWebProxy = true;
            }
            else
            {
                WebProxy webProxy = ProxyWrapper.GetWebProxy(proxy);

                binding.UseDefaultWebProxy = false;
                if (proxy.ProxyType == model.Proxy.EProxyType.Enabled)
                {
                    binding.ProxyAddress = webProxy.Address;
                }
            }

            return(binding);
        }
Exemple #9
0
 public RetrieveAsyncOp(string webSvcPath, int timeoutPeriod, wsdl.Parser parser, model.IProxy configProxy, ILog log)
     : base(webSvcPath, timeoutPeriod, configProxy, log)
 {
     _webSvcPath = webSvcPath;
     _downloader = new WsdlDownload(webSvcPath, timeoutPeriod);
     _parser     = parser;
 }
Exemple #10
0
 public UpdateAsyncOp(string updateUrl, string version, drexModel.IProxy configProxy, int timeoutPeriod)
     : base("UpdateAsyncOp", timeoutPeriod, configProxy, utils.Logger.Instance.Log)
 {
     _updateUrl = updateUrl;
     _version   = version;
 }
Exemple #11
0
        public CallAsyncOp(model.WebSvcMethod webSvcMethod, CancelToken cancelToken, int timeoutPeriod, model.IProxy proxy, ILog log)
            : base(webSvcMethod.Name, timeoutPeriod, proxy, log)
        {
            _webSvcMethod = webSvcMethod;
            _cancelToken  = cancelToken;

            _cancelObject           = new process.WebSvcAsync.CancelObject(webSvcMethod.Name, cancelToken);
            _cancelObject.OnCancel += _cancelObject_OnCancel;
        }