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()); }
// ** 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 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; }
// ** 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; }
/// <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); }
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); }
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; }
// ** DISCOVERY ** // public List<EndpointAddress> FindService() { List<EndpointAddress> service = new List<EndpointAddress>(); DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint()); Collection<EndpointDiscoveryMetadata> publishService = discoveryClient.Find(new FindCriteria(typeof(IServerManagement))).Endpoints; discoveryClient.Close(); foreach (var server in publishService) { service.Add(server.Address); } return service; }
static bool FindService() { Console.WriteLine("\nFinding Myservice Service .."); DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint()); var Services = discoveryClient.Find(new FindCriteria(typeof(Service.IService1))); discoveryClient.Close(); if (Services == null) { Console.WriteLine("\nNo services are found."); return false; } else { serviceAddress = Services.Endpoints[0].Address; return true; } }
protected override void Execute(CodeActivityContext context) { DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint()); FindCriteria findCriteria = new FindCriteria(); // Create a contract to add to the findCriteria. The search will be based on this contract. findCriteria.ContractTypeNames.Add(new XmlQualifiedName("IPrintService", "http://tempuri.org/")); findCriteria.MaxResults = 1; findCriteria.Duration = new TimeSpan(0, 0, 0, 3); FindResponse findResponse = discoveryClient.Find(findCriteria); discoveryClient.Close(); if (findResponse.Endpoints.Count == 0) { throw new EndpointNotFoundException("Client was unable to find any matching endpoints using Discovery."); } this.DiscoveredEndpointUri.Set(context, findResponse.Endpoints[0].Address.Uri); }
private FindResponse PerformEndpointSearch(Type contract, DiscoveredEndpointModel model) { var criteria = CreateSearchCriteria(contract, model); for (int i = 0; i < 2; ++i) { var discoveryEndpoint = GetDiscoveryEndpoint(model); WcfBindingUtils.ConfigureQuotas(discoveryEndpoint.Binding, int.MaxValue); var discoveryClient = new DiscoveryClient(discoveryEndpoint); try { return discoveryClient.Find(criteria); } catch { // ignore failures } finally { try { discoveryClient.Close(); } catch { // Discovery client often fails on close } } // Possible stale discovery proxy... if (i == 0) { var discoveryEndpointFaulted = DiscoveryEndpointFaulted; if (discoveryEndpointFaulted != null) { discoveryEndpointFaulted(this, new DiscoveryEndpointFaultEventArgs(discoveryEndpoint)); } } } return null; }
// discovers projector servers on the local net static Collection<EndpointDiscoveryMetadata> DiscoverProjectors() { using (var discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint())) { var findCriteria = new FindCriteria(typeof(ProjectorServer)) { Duration = new TimeSpan(0, 0, 2) }; var services = discoveryClient.Find(findCriteria); discoveryClient.Close(); cout.PrintVerbose("Found {0} projector servers.", services.Endpoints.Count); return services.Endpoints; } }