5

ファイルをアップロードするためのWCFサービスを作成していますが、バイト配列に16384を超える要素がある場合は例外がスローされます。

これは例外の詳細です:

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

クライアントとサーバーの両方の構成により、アレイの最大長のクォータが2147483647に設定されます。

クライアント構成:

<system.serviceModel>
  <bindings>
   <basicHttpBinding>
    <binding name="BasicHttpBinding_IDocumentLibraryService" closeTimeout="00:01:00"
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
     maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
     useDefaultWebProxy="true">
     <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
     <security mode="None">
      <transport clientCredentialType="None" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
     </security>
    </binding>
   </basicHttpBinding>
  </bindings>
  <client>
   <endpoint address="http://localhost:50764/DocumentLibraryService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDocumentLibraryService"
    contract="DocumentLibrary.IDocumentLibraryService" name="BasicHttpBinding_IDocumentLibraryService" />
  </client>

サーバー構成:

<bindings>

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

            <service name="BasicHttpBinding_IDocumentLibraryService">

                <clear />
                <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="Peninsula.DocumentLibrary.ServiceLayer.IDocumentLibraryService" />
                <endpoint binding="basicHttpBinding" name="DocumentLibraryService" contract="Peninsula.DocumentLibrary.ServiceLayer.IDocumentLibraryService" address=""
                          bindingConfiguration="BasicHttpBinding_IDocumentLibraryService"/>
            </service>
        </services>
4

2 に答える 2

2

私がする必要があるのは、web.configファイルのサービス名を名前空間を持つ完全なサービス名に変更することだけでした。

<service name="SampleNameSpace.DocumentLibraryService">

                <clear />
                <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="Peninsula.DocumentLibrary.ServiceLayer.IDocumentLibraryService" />
                <endpoint binding="basicHttpBinding" name="DocumentLibraryService" contract="Peninsula.DocumentLibrary.ServiceLayer.IDocumentLibraryService" address=""
                          bindingConfiguration="BasicHttpBinding_IDocumentLibraryService"/>
            </service>
于 2011-05-06T09:44:09.657 に答える
0

構成に問題がないように見えるため、これは実際には答えではありません。サービスホストプロキシのコード(トレースまたはデバッグへの出力)でこれらの値をチェックして、configの同じ値がチャネルにロードされていることを確認する必要があると思います。

可能性としては、別のしきい値に達し、エラーが誤解を招く可能性があります

特にXMLを使用している場合は、ファイルのアップロードにバイト配列を使用しないことを強くお勧めします。これらはXML配列として表され、構造は非常に肥大化したXMLになり、元のファイルの10倍の時間がかかります。

私は使うだろう:

  • 基本的なバインディングでも機能し、超高速のWCFストリーミング
  • または、バイト配列をbase64文字列として表します。これには33%多くのスペースが必要ですが、1000%は必要ありません

アップデート

サービスの構成に使用されたバインディング名をトレースできます(任意のWCF操作内で使用します)。

public int MyServiceOperation()
{
     Trace.WriteLine(OperationContext.Current.EndpointDispatcher.ChannelDispatcher.BindingName)
....
于 2011-05-05T11:18:36.037 に答える