internal static void RunHosts(IEnumerable<System.ServiceModel.ServiceHost> hosts) { foreach (System.ServiceModel.ServiceHost host in hosts) { //host.Description.Behaviors.Remove<System.ServiceModel.Description.ServiceDebugBehavior>(); System.ServiceModel.Description.ServiceDebugBehavior debugBehavior = host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceDebugBehavior>(); if (debugBehavior == null) { Console.WriteLine("Adding DebugBehavior"); debugBehavior = new System.ServiceModel.Description.ServiceDebugBehavior(); debugBehavior.IncludeExceptionDetailInFaults = true; host.Description.Behaviors.Add(debugBehavior); } else { Console.WriteLine("IncludeExceptionDetailInFaults={0}", debugBehavior.IncludeExceptionDetailInFaults); debugBehavior.IncludeExceptionDetailInFaults = true; } } try // To open hosts { foreach (System.ServiceModel.ServiceHost host in hosts) { host.Open(); } } // Ends try to open hosts finally // Opened hosts { foreach (System.ServiceModel.ServiceHost host in hosts) { Console.WriteLine(); if (host.State == System.ServiceModel.CommunicationState.Faulted) { host.Abort(); } else { foreach (System.ServiceModel.Description.ServiceEndpoint endpoint in host.Description.Endpoints) { Console.WriteLine("Endpoint: {0}", endpoint.Address); } Console.WriteLine(string.Format("{0} Behaviors", host.Description.Name)); foreach (System.ServiceModel.Description.IServiceBehavior behavior in host.Description.Behaviors) { Console.WriteLine(String.Format(" {0}", behavior.ToString())); } Console.WriteLine("Host State: {0}", host.State); } } // Ends loop over hosts } }
internal static void RunHosts(IEnumerable <System.ServiceModel.ServiceHost> hosts) { foreach (System.ServiceModel.ServiceHost host in hosts) { //host.Description.Behaviors.Remove<System.ServiceModel.Description.ServiceDebugBehavior>(); System.ServiceModel.Description.ServiceDebugBehavior debugBehavior = host.Description.Behaviors.Find <System.ServiceModel.Description.ServiceDebugBehavior>(); if (debugBehavior == null) { Console.WriteLine("Adding DebugBehavior"); debugBehavior = new System.ServiceModel.Description.ServiceDebugBehavior(); debugBehavior.IncludeExceptionDetailInFaults = true; host.Description.Behaviors.Add(debugBehavior); } else { Console.WriteLine("IncludeExceptionDetailInFaults={0}", debugBehavior.IncludeExceptionDetailInFaults); debugBehavior.IncludeExceptionDetailInFaults = true; } } try // To open hosts { foreach (System.ServiceModel.ServiceHost host in hosts) { host.Open(); } } // Ends try to open hosts finally // Opened hosts { foreach (System.ServiceModel.ServiceHost host in hosts) { Console.WriteLine(); if (host.State == System.ServiceModel.CommunicationState.Faulted) { host.Abort(); } else { foreach (System.ServiceModel.Description.ServiceEndpoint endpoint in host.Description.Endpoints) { Console.WriteLine("Endpoint: {0}", endpoint.Address); } Console.WriteLine(string.Format("{0} Behaviors", host.Description.Name)); foreach (System.ServiceModel.Description.IServiceBehavior behavior in host.Description.Behaviors) { Console.WriteLine(String.Format(" {0}", behavior.ToString())); } Console.WriteLine("Host State: {0}", host.State); } } // Ends loop over hosts } }
/// <summary> /// Sets all the properties to the newly published service point /// </summary> /// <remarks>Maybe this shuld be done in configuration?? Jure Subara</remarks> /// <param name="host"></param> public static void SetPublishingServiceHost(System.ServiceModel.ServiceHost host) { //do not require authorization //host.Authorization.ImpersonateCallerForAllOperations = true; host.Authorization.PrincipalPermissionMode = System.ServiceModel.Description.PrincipalPermissionMode.None; //include exception details System.ServiceModel.Description.ServiceDebugBehavior sb = null; sb = host.Description.Behaviors[typeof(System.ServiceModel.Description.ServiceDebugBehavior)] as System.ServiceModel.Description.ServiceDebugBehavior; if (sb == null) { sb = new System.ServiceModel.Description.ServiceDebugBehavior(); host.Description.Behaviors.Add(sb); } sb.IncludeExceptionDetailInFaults = true; }
/// <summary> /// Sets all the properties to the newly published service point /// </summary> /// <remarks>Maybe this shuld be done in configuration?? Jure Subara</remarks> /// <param name="host"></param> public static void SetPublishingServiceHost(System.ServiceModel.ServiceHost host) { //do not require authorization //host.Authorization.ImpersonateCallerForAllOperations = true; host.Authorization.PrincipalPermissionMode = System.ServiceModel.Description.PrincipalPermissionMode.None; //include exception details System.ServiceModel.Description.ServiceDebugBehavior sb = null; sb = host.Description.Behaviors[typeof(System.ServiceModel.Description.ServiceDebugBehavior)] as System.ServiceModel.Description.ServiceDebugBehavior; if (sb == null) { sb = new System.ServiceModel.Description.ServiceDebugBehavior(); host.Description.Behaviors.Add(sb); } sb.IncludeExceptionDetailInFaults = true; }