41

VS 2010を使用して単純なWCFサービスを開発しました。また、アプリケーションを追加して物理パスを設定することにより、IISの既定のWebサイトでホストしました。

そして、.svcファイルを参照しようとすると、次のエラーが発生します。

セクション宣言がないため、構成セクション'protocolMapping'を読み取ることができません。」

プロトコルマッピングエラー

私は多くの解決策を試しましたが、うまくいきません

作成した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>

およびiWCFWebサイト(マイクライアント)で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

6 に答える 6

63

アムル、

これは、.svcが実行されているフォルダーにアクセス許可の問題があるようです。次のアクセス許可があるかどうかを確認してください。

  • \ IIS_IUSERS
  • \IIS_IUSR---匿名モードでWebサービスを実行している場合

プロトコルマッピングの問題については、IISサイトで使用しているアプリプールが.net 4を使用するように設定されていることを確認してください。プロトコルマッピングは、.net4でのみ使用できると私は理解しています。

お役に立てれば

于 2012-10-29T14:58:41.120 に答える
25

同じ問題が発生しましたが、最終的に、個々のWebサイトのアプリケーションプールだけでなく、DEFAULTアプリケーションプールを.Net4.0に設定する必要があることがわかりました。

于 2013-02-12T13:58:10.800 に答える
22

プロトコルマッピングの問題については、IISサイトに使用しているアプリプールが.net4を使用するように設定されていることを確認してください。

ここに画像の説明を入力してください

于 2015-09-04T05:47:25.200 に答える
6

私は同じ問題に直面しています。アプリケーションプールの.netフレームワークを2.0から4.oに変更することで、私の問題は解決しました

于 2013-10-28T05:36:55.590 に答える
0

ここに画像の説明を入力してください

私も同じ問題を抱えていましたが、最終的にいくつかのWindows機能をオンにすることで問題を解決できました。

于 2020-03-28T09:43:15.887 に答える
0
<configSections>
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <section name="protocolMapping" type="System.ServiceModel.Configuration.ProtocolMappingSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </sectionGroup>
</configSections>

私のために解決されたweb.configファイルへの追加

于 2020-06-30T12:11:49.387 に答える