Reputation: 34770
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="http://ldo:8080/LLService" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ILLService" contract="LLServiceReference.ILLService"
name="WSHttpBinding_ILLService">
<identity>
<userPrincipalName value="[email protected]" />
</identity>
</endpoint>
</client>
</system.serviceModel>
...
</configuration>
Upvotes: 5
Views: 10575
Reputation: 91
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();
Upvotes: 9
Reputation: 54734
Take a look at the <system.serviceModel>
documentation in MSDN.
You should:
ServiceModelSectionGroup.GetSectionGroup
methodserviceModelSectionGroup.Client.Endpoints
collection. Presumably you want to look at a specific contract.Address
propertyUpvotes: 2