Пример #1
1
        static EndpointAddress FindCalculatorServiceAddress()
        {
            // Create DiscoveryClient
            DiscoveryEndpoint discoveryEndpoint = new DiscoveryEndpoint(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8001/DiscoveryRouter/"));
            DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint);

            Console.WriteLine("Finding ICalculatorService endpoints...");
            Console.WriteLine();

            // Find ICalculatorService endpoints            
            FindCriteria findCriteria = new FindCriteria(typeof(ICalculatorService));
            findCriteria.Duration = TimeSpan.FromSeconds(10);

            FindResponse findResponse = discoveryClient.Find(findCriteria);

            Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
            Console.WriteLine();

            if (findResponse.Endpoints.Count > 0)
            {
                return findResponse.Endpoints[0].Address;
            }
            else
            {
                return null;
            }
        }
Пример #2
0
        // ** DISCOVERY ** //
        static bool FindService()
        {
            try
            {
                DiscoveryClient discoveryClient =
                    new DiscoveryClient(new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscovery11));

                Collection<EndpointDiscoveryMetadata> services = discoveryClient.Find(new FindCriteria(typeof(IServiceHelloWCF))).Endpoints;

                discoveryClient.Close();

                if (services.Count == 0)
                {
                    return false;
                }
                else
                {
                    serviceAddress = services[0].ListenUris[0];
                }
            }
            catch
            {
                return false;
            }

            return true;
        }
        public static void OldMain(string[] args)
        {
            var endPoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);

            //not sure what this does - if anything.
            //endPoint.Binding.CreateBindingElements().Insert(0, new MulticastCapabilitiesBindingElement(true));

            var discoveryClient = new System.ServiceModel.Discovery.DiscoveryClient(endPoint);

            discoveryClient.FindProgressChanged += DiscoveryClient_FindProgressChanged;

            var findCriteria = new FindCriteria
            {
                Duration   = TimeSpan.FromSeconds(10), // Onvif device manager finds cameras almost instantly - so 10s should be plenty
                MaxResults = int.MaxValue
            };

            //Taking cue from sniffing Onvif DM UDP packets - only add one contract type filter
            findCriteria.ContractTypeNames.Add(new XmlQualifiedName("NetworkVideoTransmitter", @"http://www.onvif.org/ver10/network/wsdl"));
            //findCriteria.ContractTypeNames.Add(new XmlQualifiedName("Device", @"http://www.onvif.org/ver10/device/wsdl"));

            Console.WriteLine("Initiating find operation.");

            //discoveryClient.FindAsync(findCriteria);
            //Console.WriteLine("Returned from Async find operation");

            var response = discoveryClient.Find(findCriteria);

            Console.WriteLine($"Operation returned - Found {response.Endpoints.Count} endpoints.");

            Console.ReadKey();
        }
Пример #4
0
 public HostDiscovery(Type type)
 {
     m_ContractType = type;
     m_DiscoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
     // Change the Default Duration from 20 seconds to 5 Seconds
     m_FindDuration = new TimeSpan(0, 0, 0, 5, 0);
 }
Пример #5
0
        // ** DISCOVERY ** //
        static bool FindService()
        {
            try
            {
                DiscoveryClient discoveryClient =
                    new DiscoveryClient(new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscovery11));

                // Uncomment to support WSDiscoveryApril2005 discovery (and change app.config for binding change)
                //DiscoveryClient discoveryClient =
                //    new DiscoveryClient(new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005)); 

                Collection<EndpointDiscoveryMetadata> services = discoveryClient.Find(new FindCriteria(typeof(IServiceHelloWCF))).Endpoints;

                discoveryClient.Close();

                if (services.Count == 0)
                {
                    return false;
                }
                else
                {
                    serviceAddress = services[0].ListenUris[0];
                }
            }
            catch
            {
                return false;
            }

            return true;
        }
Пример #6
0
        public static void Main()
        {
            Uri probeEndpointAddress = new Uri("net.tcp://localhost:8001/Probe");
            DiscoveryEndpoint discoveryEndpoint = new DiscoveryEndpoint(new NetTcpBinding(), new EndpointAddress(probeEndpointAddress));

            DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint);

            Console.WriteLine("Finding ICalculatorService endpoints using the proxy at {0}", probeEndpointAddress);
            Console.WriteLine();

            try
            {
                FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(ICalculator)));

                Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
                Console.WriteLine();

                if (findResponse.Endpoints.Count > 0)
                {
                    InvokeCalculatorService(findResponse.Endpoints[0].Address);
                }
            }
            catch (TargetInvocationException)
            {
                Console.WriteLine("This client was unable to connect to and query the proxy. Ensure that the proxy is up and running.");
            }
        }
Пример #7
0
        public static void Main()
        {
            // Create DiscoveryClient
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());

            Console.WriteLine("Finding ICalculatorService endpoints...");
            Console.WriteLine();

            // Find ICalculatorService endpoints
            FindCriteria findCriteria = new FindCriteria(typeof(ICalculatorService));
            findCriteria.Duration = TimeSpan.FromSeconds(5);

            FindResponse findResponse = discoveryClient.Find(findCriteria);

            Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
            Console.WriteLine();

            // Check to see if endpoints were found & print the XML metadata in them.
            if (findResponse.Endpoints.Count > 0)
            {
                foreach (XElement xElement in findResponse.Endpoints[0].Extensions)
                {
                    Console.WriteLine("Printing Metadata from ServiceEndpoint:");
                    Console.WriteLine("Endpoint Information: " + xElement.Element("Information").Value);
                    Console.WriteLine("Endpoint Started at Time: " + xElement.Element("Time").Value);
                    Console.WriteLine();
                }
                InvokeCalculatorService(findResponse.Endpoints[0].Address);
            }
            Console.WriteLine("Press <ENTER> to exit.");
            Console.ReadLine();
        }
Пример #8
0
        static EndpointAddress FindCalculatorServiceAddress()
        {
            // Create a discovery client using the secure endpoint that applies and checks the compact signature
            DiscoveryClient discoveryClient = new DiscoveryClient("udpSecureDiscoveryEndpoint");

            Console.WriteLine("Finding ICalculatorService endpoints...");
            Console.WriteLine();

            FindCriteria findCriteria = new FindCriteria(typeof(ICalculatorService));
            findCriteria.Duration = TimeSpan.FromSeconds(5);

            // Find ICalculatorService endpoints
            FindResponse findResponse = discoveryClient.Find(findCriteria);

            Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
            Console.WriteLine();
            if (findResponse.Endpoints.Count > 0)
            {
                return findResponse.Endpoints[0].Address;
            }
            else
            {
                return null;
            }
        }
Пример #9
0
        public static void Main()
        {
            var dnsName = Dns.GetHostName();
            // Create a DiscoveryEndpoint that points to the DiscoveryProxy
            var probeEndpointAddress = new Uri(string.Format("http://{0}:8001/Probe", dnsName));
            var discoveryEndpoint = new DiscoveryEndpoint(new BasicHttpBinding(), new EndpointAddress(probeEndpointAddress));

            var discoveryClient = new DiscoveryClient(discoveryEndpoint);

            Console.WriteLine("Finding ICalculatorService endpoints using the proxy at {0}", probeEndpointAddress);
            Console.WriteLine();

            try
            {
                // Find ICalculatorService endpoints
                FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(ICalculatorService)));

                Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
                Console.WriteLine();

                // Check to see if endpoints were found, if so then invoke the service.
                if (findResponse.Endpoints.Count > 0)
                {
                    InvokeCalculatorService(findResponse.Endpoints[0].Address);
                }
            }
            catch (TargetInvocationException)
            {
                Console.WriteLine("This client was unable to connect to and query the proxy. Ensure that the proxy is up and running.");
            }

            Console.WriteLine("Press <ENTER> to exit.");
            Console.ReadLine();
        }
		private void ProbeInitialServices(ServiceHost serviceHost)
		{
			var probe = new DiscoveryClient(UdpDiscoveryEndpoint ?? new UdpDiscoveryEndpoint());
			probe.FindProgressChanged += (_, args) => RegisterService(serviceHost, args.EndpointDiscoveryMetadata);
			probe.FindCompleted += (_, args) => probe.Close();
			probe.FindAsync(ProbeCriteria ?? new FindCriteria());
		}
Пример #11
0
        /// <summary>
        /// Starts a discovery process
        /// </summary>
        public void Find( DiscoveryType type = DiscoveryType.WsDiscovery )
        {
            ActivityServices.Clear();
#if !ANDROID
           

            switch ( type )
            {
                case DiscoveryType.WsDiscovery:
                    using ( var wsBrowser = new DiscoveryClient( new UdpDiscoveryEndpoint() ) )
                    {
                        wsBrowser.FindProgressChanged += WsBrowserFindProgressChanged;
                        wsBrowser.FindCompleted += WsBrowserFindCompleted;
                        wsBrowser.FindAsync( new FindCriteria( typeof( IDiscovery ) ) );
                    }
                    break;
                case DiscoveryType.Zeroconf:
                {
                    var zcBrowser = new ServiceBrowser();
                    zcBrowser.ServiceAdded += zcBrowser_ServiceAdded;
                    zcBrowser.Browse( "_am._tcp", "local" );
                }
                    break;
            }
#else
            Probe();
#endif
        }
Пример #12
0
      public static void Main(string[] args)
      {
          var endPoint        = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);
          var discoveryClient = new System.ServiceModel.Discovery.DiscoveryClient(endPoint);

          var findCriteria = new FindCriteria
          {
              Duration   = TimeSpan.FromSeconds(3),
              MaxResults = int.MaxValue
          };

          findCriteria.ContractTypeNames.Add(new XmlQualifiedName("NetworkVideoTransmitter", @"http://www.onvif.org/ver10/network/wsdl"));

          Console.WriteLine("Initiating find operation.");

          var           response = discoveryClient.Find(findCriteria);
          List <string> lst      = new List <string>();

          foreach (var e in response.Endpoints)
          {
              foreach (var item in e.ListenUris)
              {
                  string uri  = item.OriginalString;
                  string host = item.Host;
                  lst.Add(host + ": " + uri);
              }
          }
          lst = lst.Distinct().ToList();
          lst.ForEach(x => Console.WriteLine(x));

          Console.WriteLine($"Operation returned - Found {lst.Count} endpoints.");
          Console.ReadKey();
      }
Пример #13
0
        public static LobbyWindow lanGame(UserAccount account, ILobbyGUI gui)
        {
            DiscoveryClient dc = new DiscoveryClient(new UdpDiscoveryEndpoint());
            FindCriteria fc = new FindCriteria(typeof(IDiscoveryTest));
            fc.Duration = TimeSpan.FromSeconds(5);
            FindResponse fr = dc.Find(fc);

            if (fr.Endpoints.Count > 0)
            {
                ip = fr.Endpoints[0].Address.Uri.Host.ToString();
            }
            else
            {
                string HostName = System.Net.Dns.GetHostName();
                System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostByName(HostName);
                string IpAdresse = hostInfo.AddressList[0].ToString();
                ip = IpAdresse;
                Server server = new Server(new WCFTCPServiceFactory(),ip);
                server.run();
            }

            factory = new WCFTCPConnectionFactory();
            lobbyWindow = new LobbyWindow(account, gui, factory);
            factory.connectToLobby(ip, lobbyWindow);

            return lobbyWindow;
        }
Пример #14
0
        static EndpointAddress FindCalculatorServiceAddress()
        {
            // Create DiscoveryClient
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());

            // Find ICalculatorService endpoints in the specified scope            
            Uri scope = new Uri("ldap:///ou=engineering,o=exampleorg,c=us");
            FindCriteria findCriteria = new FindCriteria(typeof(ICalculatorService));
            findCriteria.Scopes.Add(scope);
            findCriteria.MaxResults = 1;

            Console.WriteLine("Finding ICalculatorService endpoints within {0} scope...", scope);
            Console.WriteLine();
            
            FindResponse findResponse = discoveryClient.Find(findCriteria);

            Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
            Console.WriteLine();

            if (findResponse.Endpoints.Count > 0)
            {
                return findResponse.Endpoints[0].Address;
            }
            else
            {
                return null;
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            // Create a DiscoveryEndpoint that points to the DiscoveryProxy
            Uri probeEndpointAddress = new Uri("net.tcp://localhost:8001/Probe");
            DiscoveryEndpoint discoveryEndpoint = new DiscoveryEndpoint(new NetTcpBinding(), new EndpointAddress(probeEndpointAddress));

            DiscoveryClient discoveryClient = new DiscoveryClient(discoveryEndpoint);

            Console.WriteLine("Finding ICalculatorService endpoints using the proxy at {0}", probeEndpointAddress);
            Console.WriteLine();

            try
            {
                // Find ICalculatorService endpoints
                FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(ICalculatorService)));

                Console.WriteLine("Found {0} ICalculatorService endpoint(s).", findResponse.Endpoints.Count);
                Console.WriteLine();

                // Check to see if endpoints were found, if so then invoke the service.
                if (findResponse.Endpoints.Count > 0)
                {
                    InvokeCalculatorService(findResponse.Endpoints[0].Address);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("This client was unable to connect to and query the proxy. Ensure that the proxy is up and running.");
            }

            Console.WriteLine("Press <ENTER> to exit.");
            Console.ReadLine();
        }
Пример #16
0
        public static MediaDevice[] GetAvailableMediaDevices()
        {
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005));
            FindCriteria findCriteria = new FindCriteria
            {
                Duration = TimeSpan.FromSeconds(1),
                MaxResults = 15
            };

            findCriteria.ContractTypeNames.Add(new XmlQualifiedName("NetworkVideoTransmitter", @"http://www.onvif.org/ver10/network/wsdl"));

            FindResponse findResponse = discoveryClient.Find(findCriteria);

            List<MediaDevice> cameras = new List<MediaDevice>();

            foreach (var point in findResponse.Endpoints)
            {
                Uri uri = point.ListenUris.FirstOrDefault(u => u.HostNameType == UriHostNameType.IPv4);
                if (uri != null)
                {
                    string name = ONVIFAgent.GetDeviceInformation(uri);

                    cameras.Add(new MediaDevice(name, uri));
                }
            }
            return cameras.ToArray();
        }
Пример #17
0
		public EndpointAddress DiscoverMaster()
		{
			DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
			var orationiServices = discoveryClient.Find(new FindCriteria(typeof(IOrationiMasterService)));
			discoveryClient.Close();
			return orationiServices.Endpoints.Count == 0 ? null : orationiServices.Endpoints[0].Address;
		}
Пример #18
0
        public static EndpointAddress DiscoverAddress()
        {
            Console.WriteLine("Discovery stated at " + DateTime.Now);

            // Create DiscoveryClient
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());

            // Find ICalculatorService endpoints
            FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(IDatagramService)));

            Console.WriteLine("Discovery finished at " + DateTime.Now);

            if (findResponse.Endpoints.Count> 0)
            {
                foreach (var e in findResponse.Endpoints)
                {
                    Console.WriteLine(e.Address + ", ContractTypeNames:" + e.ContractTypeNames
                        + ", Scopes:" + e.Scopes + ", ListenUris:" + e.ListenUris);
                }

                return findResponse.Endpoints[0].Address;

            }
            else
            {
                Console.WriteLine("No service found.");
                return null;
            }
        }
		private DiscoveryEndpoint DiscoverEndpoint(DiscoveryEndpoint endpoint, bool required)
		{
			using (var discover = new DiscoveryClient(UdpDiscoveryEndpoint ?? new UdpDiscoveryEndpoint()))
			{
				var criteria = new FindCriteria(endpoint.Contract.ContractType) { MaxResults = 1 };
				if (DiscoveryDuration.HasValue)
				{
					criteria.Duration = DiscoveryDuration.Value;
				}

				var discovered = discover.Find(criteria);
				if (discovered.Endpoints.Count > 0)
				{
					var endpointMetadata = discovered.Endpoints[0];
					var binding = Binding ?? AbstractChannelBuilder.GetBindingFromMetadata(endpointMetadata);
					return new DiscoveryEndpoint(binding, endpointMetadata.Address);
				}

				if (required)
				{
					throw new EndpointNotFoundException("Unable to locate a ServiceCatalog on the network.");
				}

				return null;
			}
		}
Пример #20
0
        /// <summary>
        /// Starts a discovery process
        /// </summary>
        public void Find(DiscoveryType type = DiscoveryType.WSDiscovery)
        {
            ActivityServices.Clear();
#if !ANDROID
            switch (type)
            {
                case DiscoveryType.WSDiscovery:
                    using (var wsBrowser = new DiscoveryClient(new UdpDiscoveryEndpoint()))
                    {
                        wsBrowser.FindProgressChanged += WSBrowserFindProgressChanged;
                        wsBrowser.FindCompleted += WSBrowserFindCompleted;
                        wsBrowser.FindAsync(new FindCriteria(typeof(IDiscovery)));
                    }
                    break;
                case DiscoveryType.Zeroconf:
                    {
                        var zcBrowser = new ServiceBrowser();
                        zcBrowser.ServiceAdded += delegate(object o, ServiceBrowseEventArgs args)
                        {
                            args.Service.Resolved += ZcBrowserServiceResolved;
                            args.Service.Resolve();
                        };
                        zcBrowser.Browse("_am._tcp", "local");
                        
                    }
                    break;
            }

            switch (type)
            {
                case DiscoveryType.WSDiscovery:
                    using (var wsBrowser = new DiscoveryClient(new UdpDiscoveryEndpoint()))
                    {
                        wsBrowser.FindProgressChanged += WSBrowserFindProgressChanged;
                        wsBrowser.FindCompleted += WSBrowserFindCompleted;
                        wsBrowser.FindAsync(new FindCriteria(typeof(IDiscovery)));
                    }
                    break;
                case DiscoveryType.Zeroconf:
                    {
                        var zcBrowser = new ServiceBrowser();
                        zcBrowser.ServiceAdded += delegate(object o, ServiceBrowseEventArgs args)
                        {
                            args.Service.Resolved += ZcBrowserServiceResolved;
                            args.Service.Resolve();
                        };
                        zcBrowser.Browse("_am._tcp", "local");

                    }
                    break;
            }
#else
            Probe();
#endif
        }
Пример #21
0
 public EndpointAddress FindNotifierServiceAddress(int secondsTimeout)
 {
     DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
     FindCriteria criteria = new FindCriteria(typeof(INotifierService)) { Duration = new TimeSpan(0, 0, 0, secondsTimeout) };
     FindResponse findResponse = discoveryClient.Find(criteria);
     if (findResponse.Endpoints.Count > 0)
     {
         return findResponse.Endpoints[0].Address;
     }
     return null;
 }
Пример #22
0
        public ResolveAsyncResult(ResolveCriteria resolveCriteria, DiscoveryEndpoint forwardingDiscoveryEndpoint, AsyncCallback callback, object state)
            : base(callback, state)
        {
            this.resolveCriteria = resolveCriteria;

            this.discoveryClient = new DiscoveryClient(forwardingDiscoveryEndpoint);
            this.discoveryClient.ResolveCompleted += new EventHandler<ResolveCompletedEventArgs>(ResolveCompleted);

            // Forwards the Resolve request message
            this.discoveryClient.ResolveAsync(resolveCriteria);
        }
        /// <summary>
        /// Starts this instance.
        /// </summary>
        public void Start()
        {
            findCriteria = new FindCriteria(typeof(IAgent))
            {
                Scopes = { connectionsHostOptions.Scope },
                Duration = TimeSpan.FromMilliseconds(options.DiscoveryIntervalInMiliseconds)
            };
            discoveryClient = GetInitilizedDisoveryClient();
            log.Info("Starting clients tracking");

            Discover();
        }
        /// <summary>
        /// Returns list of addresses of sync service in network.
        /// </summary>
        /// <returns>List of addresses.</returns>
        public static IEnumerable<EndpointAddress> GetAddressesOfService()
        {
            var discoverclient = new DiscoveryClient(new UdpDiscoveryEndpoint());

            FindResponse response = discoverclient.Find(new FindCriteria(typeof (ISyncService)));
            discoverclient.Close();

            return
                response.Endpoints.Where(e => e.Address.ToString().ToUpper()
                                            != Constants.LocalSyncServiceEndpointAddress.ToUpper())
                                  .Select(e => e.Address);
        }
Пример #25
0
        static void FindCalculatorServiceAddress()
        {
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());

            discoveryClient.FindCompleted += new EventHandler<FindCompletedEventArgs>(ClientFindCompleted);
            discoveryClient.FindProgressChanged += new EventHandler<FindProgressChangedEventArgs>(ClientFindProgressChanged);

            Console.WriteLine("Finding ICalculatorServices endpoints asynchronously...\n");
            FindCriteria findCriteria = new FindCriteria(typeof(ICalculatorService));
            findCriteria.Duration = TimeSpan.FromSeconds(5);

            // Find ICalculatorService endpoint asynchronously. The results are returned asynchronously via events            
            discoveryClient.FindAsync(findCriteria);
        }
Пример #26
0
        public FindAsyncResult(FindRequestContext findRequestContext, DiscoveryEndpoint forwardingDiscoveryEndpoint, AsyncCallback callback, object state)
            : base(callback, state)
        {
            // Store the context. Responses will be added to this context
            this.findRequestContext = findRequestContext;

            // Attach delegates which will handle the find responses
            this.discoveryClient = new DiscoveryClient(forwardingDiscoveryEndpoint);
            this.discoveryClient.FindProgressChanged += new EventHandler<FindProgressChangedEventArgs>(FindProgressChanged);
            this.discoveryClient.FindCompleted += new EventHandler<FindCompletedEventArgs>(FindCompleted);

            // Forward the Probe request message
            this.discoveryClient.FindAsync(findRequestContext.Criteria);
        }        
Пример #27
0
        public void Find_Service_Publisher_Ok()
        {
            DiscoveryClient discoveryClient =
                new DiscoveryClient(new UdpDiscoveryEndpoint());

            var publisherServices =
                discoveryClient.Find(new FindCriteria(typeof(IPublisher)));

            discoveryClient.Close();

            Assert.False(publisherServices.Endpoints.Count == 0);
            var serviceAddress = publisherServices.Endpoints[0].Address;
            Assert.IsNotNull(serviceAddress);
        }
Пример #28
0
        static EndpointAddress FindCalculatorServiceAddress()
        {
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
            FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(ICalculator)));

            if (findResponse.Endpoints.Count > 0)
            {
                return findResponse.Endpoints[0].Address;
            }
            else
            {
                return null;
            }
        }
Пример #29
0
        public static ObservableCollection<EndpointAddress> ServicesAddressList()
        {
            var discoveryClient =
                new DiscoveryClient(new UdpDiscoveryEndpoint());

            var viewerServices =
                discoveryClient.Find(new FindCriteria(typeof(IRemoteService)));

            discoveryClient.Close();

            var findServiceList =
                new ObservableCollection<EndpointAddress>(viewerServices.Endpoints.Select(endpoint => endpoint.Address).ToList());

            return findServiceList;
        }
        public static IList<EndpointDiscoveryMetadata> SearchServices()
        {
            DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
            try
            {
                FindResponse discoveryResponse = discoveryClient.Find(new FindCriteria(typeof(IComplexNetworkWorkerService)));
                endpoints = discoveryResponse.Endpoints;
            }
            catch (Exception)
            {
                endpoints = new List<EndpointDiscoveryMetadata>();

            }

            return endpoints;
        }
Пример #31
0
 public static Uri WcfTestClient_DiscoverChannel()
 {
     var dc = new DiscoveryClient(new UdpDiscoveryEndpoint());
     FindCriteria fc = new FindCriteria(typeof(IWcfPingTest));
     fc.Duration = TimeSpan.FromSeconds(20);
     FindResponse fr = dc.Find(fc);
     foreach (EndpointDiscoveryMetadata edm in fr.Endpoints)
     {
         Console.WriteLine("uri found = " + edm.Address.Uri.ToString());
     }
     // here is the really nasty part
     // i am just returning the first channel, but it may not work.
     // you have to do some logic to decide which uri to use from the discovered uris
     // for example, you may discover "127.0.0.1", but that one is obviously useless.
     // also, catch exceptions when no endpoints are found and try again.
     return fr.Endpoints[0].Address.Uri;
 }
Пример #32
0
        public void TestMethod1()
        {
            var disco = new DiscoveryClient(new UdpDiscoveryEndpoint());
            var response = disco.Find(
                new FindCriteria(typeof(IMagicOracle))
                {
                    Duration = TimeSpan.FromSeconds(2)
                });

            Assert.AreNotEqual(0, response.Endpoints.Count);

            client = ChannelFactory<IMagicOracle>.CreateChannel(
                new NetNamedPipeBinding(),
                response.Endpoints[0].Address);

            var result = client.Answer("Hoe laat is het?");
            Console.WriteLine(result);
        }
Пример #33
0
        public static void Main(string[] args)
        {
            var endPoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);

            var discoveryClient = new System.ServiceModel.Discovery.DiscoveryClient(endPoint);

            discoveryClient.FindProgressChanged += DiscoveryClient_FindProgressChanged;

            var findCriteria = new FindCriteria
            {
                Duration   = TimeSpan.FromSeconds(10),
                MaxResults = int.MaxValue
            };

            findCriteria.ContractTypeNames.Add(new XmlQualifiedName("NetworkVideoTransmitter", @"http://www.onvif.org/ver10/network/wsdl"));

            Console.WriteLine("Initiating find operation.");
            var response = discoveryClient.Find(findCriteria);

            Console.WriteLine($"Operation returned - Found {response.Endpoints.Count} endpoints.");

            Console.ReadKey();
        }