Ở đây tôi đang cố gắng để đọc địa chỉ điểm cuối dịch vụ của tôi theo tên từ web.configđọc WCF dịch vụ thiết bị đầu cuối địa chỉ theo tên từ 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();
Có cách nào tôi có thể đọc địa chỉ điểm cuối dựa trên tên ?
Đây là web.config
tập tin của tôi
<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>
này sẽ làm việc clientSection.Endpoints[0];
, nhưng tôi đang tìm kiếm một cách để lấy theo tên.
I.e. một cái gì đó như clientSection.Endpoints["SecService"]
, nhưng nó không hoạt động.
Và câu hỏi của bạn là ....? Bạn có gặp lỗi không? Ko có kết quả? – Tim
Bạn chỉ nhận được nó bằng cách sử dụng ConfigurationManager? – Kiquenet