Здесь я пытаюсь прочитать адрес конечной точки службы по имени из web.config
ClientSection clientSection = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
var el = clientSection.Endpoints("SecService"); // I don't want to use index here as more endpoints may get added and its order may change
string addr = el.Address.ToString();
Есть ли способ читать адрес конечной точки на основе имени?
Вот мой web.config
файл
<system.serviceModel>
<client>
<endpoint address="https://....................../FirstService.svc" binding="wsHttpBinding" bindingConfiguration="1ServiceBinding" contract="abc.firstContractName" behaviorConfiguration="FirstServiceBehavior" name="FirstService" />
<endpoint address="https://....................../SecService.svc" binding="wsHttpBinding" bindingConfiguration="2ServiceBinding" contract="abc.secContractName" behaviorConfiguration="SecServiceBehavior" name="SecService" />
<endpoint address="https://....................../ThirdService.svc" binding="wsHttpBinding" bindingConfiguration="3ServiceBinding" contract="abc.3rdContractName" behaviorConfiguration="ThirdServiceBehavior" name="ThirdService" />
</client>
</system.serviceModel>
Это будет работать clientSection.Endpoints[0];
, но я ищу способ получить по имени.
т.е. что-то вроде clientSection.Endpoints["SecService"]
, но оно не работает.