Reputation: 6470
I have a WCF service. It uses settings from configuration file. It contains some sub-services working via http, net.tcp etc. I'd like to create a method which will return all configured endpoints urls. It will be used to provide client app possibility to receive url strings.
How I can do it inside of WCF service?
Upvotes: 0
Views: 472
Reputation: 373
You can try something like that:
private static List<Uri> GetClientsInfo()
{
var adressList = new List<Uri>();
var clientSection = (ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection);
if (clientSection != null)
{
foreach (ChannelEndpointElement endPoint in clientSection.Endpoints)
{
adressList.Add(endPoint.Address);
}
}
return adressList;
}
Also you can use "WebConfigurationManager" instead "ConfigurationManager" (depends of your Application type, more here What's the difference between the WebConfigurationManager and the ConfigurationManager?)
Upvotes: 1