Ошибка при сопоставлении протоколов При размещении службы WCF в IIS
Я разработал простую службу WCF с VS 2010. И я разместил на веб-сайте по умолчанию в IIS, добавив приложение и установив физический путь
И я попытался просмотреть файл .svc, он дал мне следующую ошибку:
"Раздел конфигурации" protocolMapping "не может быть прочитан, поскольку в нем отсутствует объявление раздела"
![Protocol Mapping Error]()
и я попробовал много решений, но не работает
Созданная библиотека WCF Service Library имеет App.config с этим:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="EvalServiceLibrary.EvalService">
<clear />
<endpoint address="basic" binding="basicHttpBinding" contract="EvalServiceLibrary.IEvalService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="ws" binding="wsHttpBinding" contract="EvalServiceLibrary.IEvalService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8888/evalservice" binding="netTcpBinding"
contract="EvalServiceLibrary.IEvalService" listenUriMode="Explicit">
<identity>
<dns value="localhost" />
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
<endpoint address="net.pipe://localhost/evalservice" binding="netNamedPipeBinding"
bindingConfiguration="" contract="EvalServiceLibrary.IEvalService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/evalservice" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
и я Хостинг приложения Библиотеки служб WCF на веб-сайте WCF (Мой клиент) имеет Web.config с этим:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="EvalServiceLibrary.EvalService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="EvalServiceLibrary.IEvalService" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="" contract="EvalServiceLibrary.IEvalService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Ответы
Ответ 1
Амр,
Похоже, что у вас могут быть проблемы с разрешениями в папке, из которой вы запускаете .svc, пожалуйста, вы можете проверить и посмотреть, есть ли следующие разрешения:
- \IIS_IUSERS
- \IIS_IUSR --- При запуске webservice в анонимном режиме
Для проблемы с сопоставлением протоколов убедитесь, что пул приложений, который вы используете для сайта IIS, настроен на использование .net 4, поскольку, насколько я понимаю, сопоставление протоколов доступно только в .net 4.
Надеюсь, что это поможет
Ответ 2
У меня была такая же проблема, но, наконец, выяснилось, что вы должны установить пул приложений DEFAULT для .Net 4.0, а не только для пула приложений для отдельного веб-сайта.
Ответ 3
Для проблемы с протокольным сопоставлением убедитесь, что пул приложений, который вы используете для сайта IIS, настроен на использование .net 4.
![введите описание изображения здесь]()
Ответ 4
У меня такая же проблема. Изменив структуру пула приложений .net с 2.0 на 4.o, была решена моя проблема.