Retrieving WCF Configuration from C#
WcfConfigDetails details = new WcfConfigDetails();
details.Populated = false;
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ServiceModelSectionGroup serviceModel = ServiceModelSectionGroup.GetSectionGroup(appConfig);
BindingsSection bindings = serviceModel.Bindings;
ChannelEndpointElement element = (from ChannelEndpointElement p in serviceModel.Client.Endpoints
where p.Name == endPointName
select p).FirstOrDefault();
if (element == null) { return details; }
details.Port = element.Address.Port;
details.HostName = element.Address.Host.ToString();
details.Populated = true;
return details;
details.Populated = false;
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ServiceModelSectionGroup serviceModel = ServiceModelSectionGroup.GetSectionGroup(appConfig);
BindingsSection bindings = serviceModel.Bindings;
ChannelEndpointElement element = (from ChannelEndpointElement p in serviceModel.Client.Endpoints
where p.Name == endPointName
select p).FirstOrDefault();
if (element == null) { return details; }
details.Port = element.Address.Port;
details.HostName = element.Address.Host.ToString();
details.Populated = true;
return details;
Comments
Post a Comment