Exemple #1
0
        public List <ServerAndEndpointsPair> Discover(string discoveryUrl, int operationTimeout)
        {
            Uri uri = new TrimmedUri(discoveryUrl);

            EndpointConfiguration configuration = EndpointConfiguration.Create();

            if (operationTimeout > 0)
            {
                configuration.OperationTimeout = operationTimeout;
            }

            System.Diagnostics.Trace.WriteLine("--- uri ---");
            System.Diagnostics.Trace.WriteLine(uri.ToString());

            ApplicationDescriptionCollection servers;

            using (DiscoveryClient client = DiscoveryClient.Create(uri, configuration))
            {
                servers = client.FindServers(null);
            }

            System.Diagnostics.Trace.WriteLine("--- End Find Servers ---");
            foreach (var s in servers)
            {
                System.Diagnostics.Trace.WriteLine("--- Start of Server ---");
                System.Diagnostics.Trace.WriteLine(string.Format("  ApplicationName    : {0}", s.ApplicationName));
                System.Diagnostics.Trace.WriteLine(string.Format("  ApplicationUri     : {0}", s.ApplicationUri));
                System.Diagnostics.Trace.WriteLine(string.Format("  # of DiscoveryURLs : {0}", s.DiscoveryUrls.Count));
                foreach (var url in s.DiscoveryUrls)
                {
                    System.Diagnostics.Trace.WriteLine(string.Format("    DiscoveryURL : {0}", url));
                }
                System.Diagnostics.Trace.WriteLine("--- End   of Server ---");
            }

            var discoveredServers = new List <ServerAndEndpointsPair>();

            foreach (var s in servers)
            {
                foreach (var url in s.DiscoveryUrls)
                {
                    System.Diagnostics.Trace.WriteLine("--- In foreach(s.DiscoveryUrls) ---");

                    var discoveredServer = new ServerAndEndpointsPair(url, s.ApplicationName.Text, configuration);

                    discoveredServers.Add(discoveredServer);
                }
            }

            System.Diagnostics.Trace.WriteLine("--- End of Discover method ---");

            return(discoveredServers);
        }
Exemple #2
0
        public void BrowseSecurityList(ServerAndEndpointsPair discoveredServer)
        {
            var url           = discoveredServer.DiscoveryURL;
            var configuration = discoveredServer.EndpointConfiguration;

            using (DiscoveryClient client = DiscoveryClient.Create(new Uri(url), configuration))
            {
                EndpointDescriptionCollection endpointCollection = null;

                System.Diagnostics.Trace.WriteLine("--- Begin of GetEndpoints ---");

                client.GetEndpoints(null, url, null, null, out endpointCollection);

                System.Diagnostics.Trace.WriteLine("--- End   of GetEndpoints ---");

                discoveredServer.Endpoints = endpointCollection;
            }
        }