我的朋友有以下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>
Run Code Online (Sandbox Code Playgroud)
小智 9
试试这个以获得第一个端点
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
ClientSection clientSection = serviceModelSectionGroup.Client;
var el = clientSection.Endpoints[0];
return el.Address.ToString();
Run Code Online (Sandbox Code Playgroud)
查看<system.serviceModel>MSDN 中的文档。
你应该:
ServiceModelSectionGroup.GetSectionGroup方法serviceModelSectionGroup.Client.Endpoints。想必您想查看特定的合同。Address属性