tags:

views:

61

answers:

1

Is there a way to list all the WCF client endpoints in an application config file?

I need to establish multiple client connections to different servers and want to find a way to still maintain all the client connection information in the application config file.

+3  A: 

Try this:

// using System.ServiceModel.Configuration;
ServiceModelSectionGroup serviceModelSectionGroup =
    ServiceModelSectionGroup.GetSectionGroup(
        ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None));
foreach (ServiceElement serviceElement in
    serviceModelSectionGroup.Services.Services.OfType<ServiceElement>())
{
    // do stuff
}
Rubens Farias
+1 even smarter than my "parse the XML directly" approach! Well done!
marc_s
It's a big compliment coming from you, @marc_s, ty
Rubens Farias
serviceModelSectionGroup.Client.Endpoints was what I needed rather than the services but you provided the missing link, thanks.
sipwiz