16

WCF サービス用に次のサーバー側 app.config があります。

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="default" maxReceivedMessageSize="5000000">
          <readerQuotas maxStringContentLength="5000000" maxArrayLength="5000000" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="Core.TOAService.Service1Behavior"
        name="Core.TOAService.TOAService">
        <endpoint address="" binding="wsHttpBinding" contract="Core.TOAService.ITOAService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/Core.TOAService/TOAService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Core.TOAService.Service1Behavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

このサービスに大きなファイル (約 250 KB のみ) を渡そうとすると、svclog ファイルに例外が記録されます。

受信メッセージの最大メッセージ サイズ クォータ (65536) を超えました。クォータを増やすには、適切なバインド要素で MaxReceivedMessageSize プロパティを使用します。

構成の上部にあるバインディング セクションからわかるように、maxReceivedMessageSize を 5000000 に設定しようとしましたが、サービスはまだデフォルトの 65536 に設定されていると認識しています。 "バインディング要素?

4

3 に答える 3

28

他にも設定があります:-) タグで「maxBufferPoolSize」と「maxBufferSize」を試してください<binding>

しかし、最大の問題は、エンドポイントがそのバインディング構成を参照していないことです!

<endpoint address="" 
          binding="wsHttpBinding" contract="Core.TOAService.ITOAService">

便利になるように参照を追加する必要があります-「デフォルト」と呼ぶだけでは機能しません.....

<endpoint address="" 
          binding="wsHttpBinding" 
          bindingConfiguration="default"
          contract="Core.TOAService.ITOAService">

あなたは時代を先取りしています ;-) WCF 4 (.NET 4.0 を使用 - 2009 年後半) では、明示的に名前を付けて参照することなく、「既定のバインディング構成」を定義できますが、今のところは、エンドポイントとそのバインディング、および所有しているバインディング (または動作) 構成の間にリンクを作成する必要があります!

マルク

于 2009-08-27T20:42:53.083 に答える
16

WCF テスト クライアントの使用中にこのエラー メッセージが引き続き表示される場合は、クライアントに個別のMaxBufferSize設定があるためです。

問題を修正するには:

  1. ツリーの下部にある構成ファイルノードを右クリックします。
  2. SvcConfigEditor で編集を選択

MaxBufferSize を含む、編集可能な設定のリストが表示されます。

注: 自動生成されたプロキシ クライアントも、デフォルトで MaxBufferSize を 65536 に設定します。

于 2010-08-05T06:10:24.853 に答える
1

サイズを設定する必要がある場所がいくつかあります。あなたの場合、読み取りクォータを追加する必要があると思います。次に例を示します。

  <basicHttpBinding>
    <binding name="httpBasicBinding_Service" closeTimeout="00:03:00"
      openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00"
      maxBufferSize="2000001"
      maxBufferPoolSize="2000001" maxReceivedMessageSize="2000001">
      <readerQuotas maxDepth="2000001" maxStringContentLength="2000001"
        maxArrayLength="2000001" maxBytesPerRead="2000001" maxNameTableCharCount="2000001" />
    </binding>
  </basicHttpBinding>
于 2009-08-27T20:46:38.583 に答える