WCF- XMLデータを読んでいる間、最大namatable文字カウントクォータ(16384)を超えています

StackOverflow https://stackoverflow.com/questions/2765598

質問

wshttpbindingを使用するWCFサービスを持っています。サーバーの構成は次のとおりです。

<bindings>
      <wsHttpBinding>
        <binding name="wsHttpBinding" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

クライアント側には、WCFサービスのサービスリファレンスが含まれています。 ISERVICEで90の操作契約が限られている場合、それはうまく機能しますが、サービスリファレンスを更新できないよりも1つのOperationContractを追加する場合、またはそのサービスリファレンスを追加することができます。の これ 記事これらの構成ファイルを変更することで(つまりdevenv.exe.config、wcftestclient.exe.configおよびsvcutil.exe.config)を変更することで言及されていますが、それらの構成ファイルにそれらのバインディングを含めることでさえ、エラーがポップアップします。

エラーダウンロードがありました」http://10.0.3.112/myservice/service1.svc/mex'。 HTTPステータス400:悪い要求でリクエストが失敗しました。メタデータには、解決できない参照が含まれています: 'http://10.0.3.112/myservice/service1.svc/mex'。 XMLドキュメント(1、89549)にエラーがあります。 XMLデータを読み取っている間、最大の命名可能な文字カウントクォータ(16384)を超えています。 nameTableは、XML処理中に遭遇する文字列を保存するために使用されるデータ構造です。非反復要素名、属性名、属性値を持つ長いXMLドキュメントがこのクォータをトリガーする場合があります。このクォータは、XMLリーダーを作成するときに使用されるXMLDictionaryReaderQuotasオブジェクトのMaxNameTableCharCountプロパティを変更することにより、増加する場合があります。 1行目、位置89549。サービスが現在のソリューションで定義されている場合は、ソリューションを構築し、サービスリファレンスを再度追加してみてください。

これを解決する方法????

役に立ちましたか?

解決

以下を試してください:

Devenv.exeが配置されているビジュアルスタジオのインストールディレクトリ(例:C: Program Files Microsoft Visual Studio 9.0 Common7 IDE)をDevenv.exe.cofigに追加します

<system.serviceModel>
<client>
  <endpoint binding="customBinding" bindingConfiguration="largeServiceBinding" contract="IMetadataExchange" name="http" />
</client>

<bindings>
  <customBinding>
    <!-- NOTE: The binding name must be the same as specified in the config file of the wcf service -->
    <binding name="largeServiceBinding" >
      <textMessageEncoding>
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </textMessageEncoding>

      <httpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
    </binding>

  </customBinding>
</bindings>
</system.serviceModel>

wcf-serviceのapp.configで同じバインディングを追加します。

<bindings>
  <customBinding >
    <!-- NOTE: The binding name must be the same as specified in the devenv.exe.config file located ..\Common7\IDE folder of the VS installation directory -->
    <binding name="largeServiceBinding" >
      <textMessageEncoding>
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"
          maxNameTableCharCount="2147483647" />
      </textMessageEncoding>
      <httpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
    </binding>
  </customBinding>
</bindings>

2つのファイルからのバインディングタグの名前属性が一致する必要があることに注意してください (例:largeservicebinding)

最後に、次のMEXエンドポイントをサービスタグに追加します。

 <endpoint address="mex" binding="customBinding" contract="IMetadataExchange" bindingName="testBinding" bindingConfiguration="largeServiceBinding" name="http"/>

これは次のようになるかもしれません:

 <services>
  <service behaviorConfiguration="MyServiceBehavior"
    name="MyService.MyService">
    <endpoint address="" binding="wsHttpBinding" contract="MyService.IMyService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="customBinding" contract="IMetadataExchange" bindingName="testBinding" bindingConfiguration="largeServiceBinding" name="http"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/MyService/MyService/" />
      </baseAddresses>
    </host>
  </service>
</services>

他のヒント

私はそれがしばらく経っていることを知っていますが、私は同じ問題を抱えて、他の(よりシンプルな)解決策を見つけました CodeProjectで

そこに与えられたソリューションでは、.configファイルではなくコードに値が設定されています。

        BasicHttpBinding binding = new BasicHttpBinding();
        binding.Security.Mode = BasicHttpSecurityMode.Transport;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
        binding.MaxReceivedMessageSize = 50000000;
        binding.ReaderQuotas.MaxArrayLength = 50000000;
        binding.ReaderQuotas.MaxStringContentLength = 50000000;
        binding.ReaderQuotas.MaxNameTableCharCount = 50000000;
        EndpointAddress endpoint = new EndpointAddress(new Uri("https://server/EWS/Exchange.asmx"));
        ExchangeServicePortTypeClient ews = new ExchangeServicePortTypeClient(binding, endpoint);

ただし、.configファイルの関連する値の値を変更しました(両方で <binding> そしてその <readerQuotas> セクション)と問題を解決しました(カスタムバインディングを追加するのではなく):

                <binding name="ITransactionProcessor" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="50000000" maxBufferPoolSize="524288" maxReceivedMessageSize="50000000"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="50000000" maxArrayLength="50000000"
                        maxBytesPerRead="4096" maxNameTableCharCount="50000000" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="None" proxyCredentialType="None" 
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>

これが誰かに役立つことを願っています:)

認識すべきことの1つは、メッセージがサービスのものではなくSVCutil Readerクォータを指していることです。 Svcutilには、読み取ることができるメタデータの量に制限があります。この制限は、構成ファイルで変更できます。解決策は、svcutil用の構成ファイルを作成し、ツールと同じフォルダーに配置することです。次回SVCutilを実行すると、構成ファイル値が考慮されます。

http://geekswithblogs.net/claraoscura/archive/2007/08/20/114806.aspx

あなたのapp.configまたはdll.configでクライアントを追加します:

<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="myMex" maxReceivedMessageSize="1024000"> <!-- modify this to avoid stupid error -->
<readerQuotas maxNameTableCharCount="163840" /> <!-- DO NOT touch this one -->
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>

...

<client>
<endpoint binding="netTcpBinding" bindingConfiguration="myMex"
contract="IMetadataExchange" name="net.tcp" />

...

        </client>
    </system.serviceModel>
</configuration>

そして、あなたはそこに行きます!これはWCFの本当に迷惑なことの1つであり、Googleが頻繁にBSの多くを生み出します。これで何トンもの時間を無駄にしました。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top