开发者

WCF list all client endpoints that implement a certain contract

开发者 https://www.devze.com 2022-12-16 11:34 出处:网络
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 th

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 infor开发者_StackOverflow社区mation in the application config file.


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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消