Настройка клиента Windows Communication Foundation

1. Откройте сформированный файл настроек (App.config) из проекта GettingStartedClient. В следующем примере приведено представление созданного файла конфигурации. В разделе <system.serviceModel><endpoint> найдите элемент найдите элемент<endpoint> найдите элемент.

<?xml version="1.0" encoding="utf-8"?><configuration> <startup> <!-- specifies the version of WCF to use--> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5,Profile=Client" /> </startup> <system.serviceModel> <bindings> <!-- Uses wsHttpBinding--> <wsHttpBinding> <binding name="WSHttpBinding_ICalculator" /> </wsHttpBinding> </bindings> <client> <!-- specifies the endpoint to use when calling the service --> <endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator" contract="ServiceReference1.ICalculator" name="WSHttpBinding_ICalculator"> <identity> <userPrincipalName value="migree@redmond.corp.microsoft.com" /> </identity> </endpoint> </client> </system.serviceModel></configuration><?xml version="1.0" encoding="utf-8"?><configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5,Profile=Client" /> </startup> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_ICalculator" /> </wsHttpBinding> </bindings> <client> <endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator" contract="ServiceReference1.ICalculator" name="WSHttpBinding_ICalculator"> <identity> <userPrincipalName value="migree@redmond.corp.microsoft.com" /> </identity> </endpoint> </client> </system.serviceModel></configuration>

В этом примере настраивается конечная точка, используемая клиентом для доступа к службе, расположенной по следующему адресу: http://localhost:8000/ServiceModelSamples/Service/CalculatorService

В элементе конечной точки указано, что контракт службы ServiceReference1.ICalculator используется для взаимодействия между клиентом и службой WCF. Канал WCF настроен с привязкой WsHttpBinding, предоставленной системой. Этот контракт был сформирован с использованием функции добавления ссылки на службу в Visual Studio. В сущности, это является копией контракта, определенного в проекте GettingStartedLib. Привязка WsHttpBinding указывает HTTP в качестве транспорта, совместимые параметры безопасности и другие детали конфигурации.

2. Дополнительные сведения о использовании созданного клиента с этой конфигурацией см. раздел Как использовать клиент Windows Communication Foundation.



Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: