ここで答えが見つかりました(最後の投稿):http ://social.msdn.microsoft.com/Forums/eu/wcf/thread/f5c0ea22-1d45-484e-b2c0-e3bc9de20915
カスタム(TextOrMtomEncoder)の実装に関する最後の問題が1つあります。これは、ReaderQuotasの実装です。
私はウェブをたくさん検索しましたが、パズルの最後のピースを理解することができません。
'BindingElementExtensionElement'と'MessageEncodingBindingElement'の実装を含むクラスがあります。
MessageEncodingBindingElement実装には、次のオーバーライドが含まれています。
T GetProperty<T>(BindingContext context)
これは、TextMessageEncodingのようなデフォルトの.NETMessageEncoding実装から「借用」しました。
MSDNがそう言っているので、これは正しい実装でなければなりません。
構成はweb.configから正常に読み込まれ、両方のクラスのReaderQuotasプロパティが正しく設定されていることがわかりますが、.NETがMessageEncodingBindingElement実装からReaderQuotas構成を読み取っていないようです。
私の推測では、MessageVersionはこのメソッドを介して要求されるため、.NETはGetPropertyメソッドを使用して構成をロードします。ただし、問題は、TがXmlDictionaryReaderQuotasと等しくなることはないため、ReaderQuotasが要求され始めることはないということです。
私の質問の根本は奇妙なことです。私はIIS7.5を搭載したWindows7x64マシンで開発しています。「大きな」ファイル(100 KBなど)の投稿は私のマシンで機能します。しかし、サービスをWindows Server 2008 R2に展開すると(2つの異なるサーバーを試した)、次のエラーが発生します。
フォーマッタは、メッセージを逆シリアル化しようとしたときに例外をスローしました。パラメータ http://socialproxy.infocaster.net:argumentを逆シリアル化しようとしたときにエラーが発生しました。InnerExceptionメッセージは次のとおりです。'タイプSystem.Objectのオブジェクトの逆シリアル化中にエラーが発生しました。XMLデータの読み取り中に、配列の最大長のクォータ(16384)を超えました。このクォータは、XMLリーダーの作成時に使用されるXmlDictionaryReaderQuotasオブジェクトのMaxArrayLengthプロパティを変更することで増やすことができます。1行目、1584の位置。詳細については、InnerExceptionを参照してください。
そして、私が言ったように、それは私のマシンで動作します:-/
誰かが私がこれを解決する方法を教えてもらえますか?
よろしくお願いします!
WCFサービス構成:
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<add name="textOrMtomMessageBehavior" type="InfoCaster.SocialProxy.lib.TextOrMtom.TextOrMtomMessageBehavior, InfoCaster.SocialProxy" />
</behaviorExtensions>
<bindingElementExtensions>
<add name="textOrMtomEncoding" type="InfoCaster.SocialProxy.lib.TextOrMtom.TextOrMtomEncodingElement, InfoCaster.SocialProxy" />
</bindingElementExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="TextOrMtomBinding">
<textOrMtomEncoding messageVersion="Soap11">
<readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="204800000" maxBytesPerRead="5242880" maxNameTableCharCount="5242880" />
</textOrMtomEncoding>
<httpTransport maxBufferSize="5242880" maxReceivedMessageSize="5242880" transferMode="Buffered" authenticationScheme="Anonymous" />
</binding>
</customBinding>
</bindings>
<services>
<clear />
<service name="InfoCaster.SocialProxy.SocialProxy" behaviorConfiguration="InfoCaster.SocialProxy.ISocialProxyServiceBehavior">
<endpoint name="SocialProxyServiceEndpoint" address="" binding="customBinding" bindingConfiguration="TextOrMtomBinding" contract="InfoCaster.SocialProxy.ISocialProxy" behaviorConfiguration="InfoCaster.SocialProxy.ISocialProxyEndpointBehavior" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<clear />
<behavior name="InfoCaster.SocialProxy.ISocialProxyServiceBehavior">
<!-- 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>
<endpointBehaviors>
<clear />
<behavior name="InfoCaster.SocialProxy.ISocialProxyEndpointBehavior">
<textOrMtomMessageBehavior />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>