我的朋友有以下app.config。他希望获得address
的价值。怎么做?
<configuration>
<system.serviceModel>
...
<client>
<endpoint address="http://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>
答案 0 :(得分:8)
尝试获取第一个端点
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
ClientSection clientSection = serviceModelSectionGroup.Client;
var el = clientSection.Endpoints[0];
return el.Address.ToString();
答案 1 :(得分:2)
查看<system.serviceModel>
documentation in MSDN。
你应该:
ServiceModelSectionGroup.GetSectionGroup
方法serviceModelSectionGroup.Client.Endpoints
集合中选择一个端点。大概你想看一个特定的合同。Address
属性