0

次のエラーが表示されます:

メッセージを逆シリアル化しようとしているときに、フォーマッタが例外をスローしました: 操作 'InsertQuery' の要求メッセージの本文を逆シリアル化中にエラーが発生しました。XML データの読み取り中に、文字列コンテンツの最大長クォータ (8192) を超えました。このクォータは、XML リーダーの作成時に使用される XmlDictionaryReaderQuotas オブジェクトの MaxStringContentLength プロパティを変更することで増やすことができます。行 1、位置 33788。

MaxStringContentLength のサイズを大きくするために、以下のように Web.config を変更しました。

<?xml version="1.0"?>
<configuration>

<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- 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>
<bindings>
  <webHttpBinding>
    <binding name="webHttpBindingDev">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

それでも同じエラーが発生します:(

この問題を解決するために必要な変更を教えてください。前もって感謝します !!

4

1 に答える 1

4

Web.config ファイルは、.NET 4.0 を使用していることを示しており、Web.config で明示的に定義されたエンドポイントがないため、WCF は (*.svc ファイルの場所に基づいて) デフォルトのエンドポイントを提供しています。 、およびスキームのデフォルトのバインディングを使用しますbasicHttpBindinghttpのデフォルトmaxStringContentLengthは 8192 です。

それを変更するには、次のいずれかが必要です。

  1. エンドポイントを明示的に追加し、(バインディング構成の `name` 属性を使用して) 定義したバインディングをエンドポイントの `bindingConfiguration` 属性に割り当てます。
  2. 「name」属性を削除して、構成ファイルで定義したバインディング構成をそのタイプのバインディングのデフォルトにし、「http」のデフォルト マッピングを「basicHttpBinding」から「webHttpBinding」に変更します。

明示的なエンドポイントを介してこれを行うには、以下を Web.config ファイルの の下に追加します<system.serviceModel>

<services>
  <service name="your service name">
    <endpoint address="" binding="webHttpBinding" 
              bindingConfiguration="webHttpBindingDev" 
              contract="your fully-qualified contract name" />
  </service>
</services>

サービス名とコントラクトに適切な値を指定する必要があります。

デフォルトを設定して行うには、属性webHttpBindingを削除して、指定したバインディング構成をデフォルトとしてマークする必要があります。name

<bindings>
  <webHttpBinding>
    <binding>
      <readerQuotas maxDepth="2147483647" 
                    maxStringContentLength="2147483647"  
                    maxArrayLength="2147483647" 
                    maxBytesPerRead="2147483647" 
                    maxNameTableCharCount="2147483647" />
    </binding>
  </webHttpBinding>
</bindings>

次に、スキームwebHttpBindingのデフォルト バインディングとして設定する必要があります。http

<protocolMapping>
  <add binding="webHttpBinding" scheme="http" />
</protocolMapping>

これら 2 つの変更により、明示的なエンドポイントを追加する必要がなくなります。

また、 を使用してwebHttpBindingいるため、エンドポイントの動作に次を追加する必要があると思います。

<behaviors>
  <endpointBehaviors>
    <behavior>
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>

WCF 4 の既定のエンドポイント、バインドなどの詳細については、開発者向け Windows Communication Foundation 4 の紹介を参照してください。

于 2013-09-17T21:38:49.527 に答える