My friend has the following app.config. He wants to get the value of address
. how to do it?
<configuration>
<system.serviceModel>
...
<client>
<endpoint address="htt开发者_如何转开发p://ldo:8080/LLService" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ILLService" contract="LLServiceReference.ILLService"
name="WSHttpBinding_ILLService">
<identity>
<userPrincipalName value="ggldoe@mail.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
...
</configuration>
try this to Get first endpoint
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
ClientSection clientSection = serviceModelSectionGroup.Client;
var el = clientSection.Endpoints[0];
return el.Address.ToString();
Take a look at the <system.serviceModel>
documentation in MSDN.
You should:
- Call the
ServiceModelSectionGroup.GetSectionGroup
method - Choose an endpoint from the
serviceModelSectionGroup.Client.Endpoints
collection. Presumably you want to look at a specific contract. - Look at that endpoint's
Address
property
精彩评论