协议映射中的错误在IIS中承载WCF服务时

时间:2021-01-20 18:25:24

I developed a simple WCF service with VS 2010. And i hosted in the default website in IIS by Adding Application and set the Physical Path

我使用VS 2010开发了一个简单的WCF服务。我通过添加应用程序在IIS的默认网站中托管并设置物理路径

And i tried to browse the .svc file it gives me the following error:

我试图浏览.svc文件,它给我以下错误:

"The configuration section 'protocolMapping' cannot be read because it is missing a section declaration"

“无法读取配置部分'protocolMapping',因为它缺少部分声明”

协议映射中的错误在IIS中承载WCF服务时

and I tried many solutions but it doesn't work

我尝试了很多解决方案,但它不起作用

I Created WCF Service Library has an App.config with this:

我创建的WCF服务库有一个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's 
  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>

and i Hosted the WCF Service Library application in WCF website (My Client) has an Web.config with this:

和我在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>

4 个解决方案

#1


55  

Amr,

AMR,

This sounds like you may have permission issues in the folder you .svc is running from, please can you check and see if the following permissions are there:

这听起来你可能在.svc运行的文件夹中有权限问题,请你检查一下是否有以下权限:

  • \IIS_IUSERS
  • \ IIS_IUSERS
  • \IIS_IUSR ---If running webservice in Anonymous Mode
  • \ IIS_IUSR ---如果以匿名模式运行webservice

For the issue with protocol Mapping, please ensure that the app Pool you are using for the IIS site is setup to use .net 4, as from what I understand protocol mapping is only available in .net 4.

对于协议映射的问题,请确保您用于IIS站点的应用程序池设置为使用.net 4,因为我理解协议映射仅在.net 4中可用。

Hope this helps

希望这可以帮助

#2


22  

I had the same issue, but finally figured out that you have to set the DEFAULT application pool to .Net 4.0, not just the Application Pool for the individual website.

我遇到了同样的问题,但最终发现你必须将DEFAULT应用程序池设置为.Net 4.0,而不仅仅是单个网站的应用程序池。

#3


16  

For the issue with protocol Mapping, please ensure that the app Pool you are using for the IIS site is setup to use .net 4.

对于协议映射的问题,请确保您用于IIS站点的应用程序池设置为使用.net 4。

协议映射中的错误在IIS中承载WCF服务时

#4


6  

I have face the same issue. By changing application pool .net framework from 2.0 to 4.o was solved my problem

我面临同样的问题。通过将应用程序池.net框架从2.0更改为4.o解决了我的问题

#1


55  

Amr,

AMR,

This sounds like you may have permission issues in the folder you .svc is running from, please can you check and see if the following permissions are there:

这听起来你可能在.svc运行的文件夹中有权限问题,请你检查一下是否有以下权限:

  • \IIS_IUSERS
  • \ IIS_IUSERS
  • \IIS_IUSR ---If running webservice in Anonymous Mode
  • \ IIS_IUSR ---如果以匿名模式运行webservice

For the issue with protocol Mapping, please ensure that the app Pool you are using for the IIS site is setup to use .net 4, as from what I understand protocol mapping is only available in .net 4.

对于协议映射的问题,请确保您用于IIS站点的应用程序池设置为使用.net 4,因为我理解协议映射仅在.net 4中可用。

Hope this helps

希望这可以帮助

#2


22  

I had the same issue, but finally figured out that you have to set the DEFAULT application pool to .Net 4.0, not just the Application Pool for the individual website.

我遇到了同样的问题,但最终发现你必须将DEFAULT应用程序池设置为.Net 4.0,而不仅仅是单个网站的应用程序池。

#3


16  

For the issue with protocol Mapping, please ensure that the app Pool you are using for the IIS site is setup to use .net 4.

对于协议映射的问题,请确保您用于IIS站点的应用程序池设置为使用.net 4。

协议映射中的错误在IIS中承载WCF服务时

#4


6  

I have face the same issue. By changing application pool .net framework from 2.0 to 4.o was solved my problem

我面临同样的问题。通过将应用程序池.net框架从2.0更改为4.o解决了我的问题