static void Main(string[] args) { using (ServiceHost host = new ServiceHost(typeof(System.ServiceModel.Routing.RoutingService), new Uri("http://localhost:14552/router"))) { ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri(host.BaseAddresses[0] + "/mex"); host.Description.Behaviors.Add(smb); var routingConfig = new RoutingConfiguration(); var filter = new MatchAllMessageFilter(); var endpoints = new List <ServiceEndpoint>(); endpoints.Add(getEchoClient(15560)); endpoints.Add(getEchoClient(33344)); endpoints.Add(getEchoClient(22455)); routingConfig.FilterTable.Add(filter, endpoints, 2); RoutingBehavior routingBehavior = new RoutingBehavior(routingConfig); host.Description.Behaviors.Add(routingBehavior); host.AddServiceEndpoint(typeof(IRequestReplyRouter), new BasicHttpBinding(), ""); host.Open(); PrintServiceDescription(host); Console.ReadKey(); } }
static void Main(string[] args) { using (ServiceHost host = new ServiceHost(typeof(System.ServiceModel.Routing.RoutingService), new Uri("http://localhost:14552/router"))) { ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.HttpGetUrl = new Uri(host.BaseAddresses[0] + "/mex"); host.Description.Behaviors.Add(smb); var routingConfig = GetRoutingConfig(); RoutingBehavior routingBehavior = new RoutingBehavior(routingConfig); host.Description.Behaviors.Add(routingBehavior); host.AddServiceEndpoint(typeof(IRequestReplyRouter), new BasicHttpBinding(), ""); //start a task to update the routing config every 15 seconds var task = Task.Factory.StartNew(() => { while (true) { UpdateEndpoints(host); Thread.Sleep(15000); } }, TaskCreationOptions.LongRunning); host.Open(); PrintServiceDescription(host); // Create an AnnouncementService instance AnnouncementService announcementService = new AnnouncementService(); // Subscribe the announcement events announcementService.OnlineAnnouncementReceived += (s, e) => { Console.WriteLine("New service online, updating endpoints..."); UpdateEndpoints(host); }; announcementService.OfflineAnnouncementReceived += (s, e) => { Console.WriteLine("Existing service offline, updating endpoints..."); UpdateEndpoints(host); }; ServiceHost announcementServiceHost = new ServiceHost(announcementService); // Listen for the announcements sent over UDP multicast announcementServiceHost.AddServiceEndpoint(new UdpAnnouncementEndpoint()); announcementServiceHost.Open(); Console.WriteLine("\n"); PrintServiceDescription(announcementServiceHost); Console.ReadKey(); } }
protected internal override object CreateBehavior() { RoutingConfiguration config; if (string.IsNullOrEmpty(this.FilterTableName)) { config = new RoutingConfiguration(); config.RouteOnHeadersOnly = this.RouteOnHeadersOnly; } else { config = new RoutingConfiguration(RoutingSection.CreateFilterTable(this.FilterTableName), this.RouteOnHeadersOnly); } config.SoapProcessingEnabled = this.SoapProcessingEnabled; config.EnsureOrderedDispatch = this.EnsureOrderedDispatch; RoutingBehavior behavior = new RoutingBehavior(config); //behavior.Impersonation = this.Impersonation; return(behavior); }
protected internal override object CreateBehavior() { RoutingConfiguration config; if (string.IsNullOrEmpty(this.FilterTableName)) { config = new RoutingConfiguration(); config.RouteOnHeadersOnly = this.RouteOnHeadersOnly; } else { config = new RoutingConfiguration(RoutingSection.CreateFilterTable(this.FilterTableName), this.RouteOnHeadersOnly); } config.SoapProcessingEnabled = this.SoapProcessingEnabled; config.EnsureOrderedDispatch = this.EnsureOrderedDispatch; RoutingBehavior behavior = new RoutingBehavior(config); //behavior.Impersonation = this.Impersonation; return behavior; }