0

IIS でホストされている WCF サービスで NetMessagingBinding を使用して、Windows Server Service Bus トピックで発行されたメッセージを使用しています。

私の理解では、Windows Server Service Bus のトピックのメッセージ サイズに制限はありませんが、サブスクリプションからメッセージを逆シリアル化するときにエラーが発生します。

System.ServiceModel.Dispatcher.NetDispatcherFaultException: (...) 
The maximum string content length quota (8192) has been exceeded while reading XML data. 
This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'.  
Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type [Type]. 
The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. ---> System.Xml.XmlException: 
The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

私が見る方法では、最大文字列コンテンツを変更するために WCF の web.config で変更できる構成はありません。関連する唯一のプロパティは MaxBufferPoolSize ですが、web.config を通じて公開されていません。

使用されるバインディング構成は次のとおりです。

<bindings>
  <netMessagingBinding>
       <binding name="messagingBinding" 
                 closeTimeout="00:03:00" openTimeout="00:03:00"
                 receiveTimeout="00:03:00" sendTimeout="00:03:00"
                 prefetchCount="-1" sessionIdleTimeout="00:01:00">
       <transportSettings batchFlushInterval="00:00:01" />
     </binding>
   </netMessagingBinding>
</bindings>

前もって感謝します、

ジョアン・カルロス・デ・スーザ

4

3 に答える 3

1

この問題は、netMessagingTransport を使用するカスタム バインディングを使用して解決することもできます。このようにして、readerQuotas ノードを使用してリーダー クォータを定義できます。

<customBinding>
    <binding name="sbBindingConfiguration" sendTimeout="00:01:00" receiveTimeout="00:01:00" openTimeout="00:01:00">
      <binaryMessageEncoding>
              <readerQuotas maxDepth="100000000" maxStringContentLength="100000000" 
                    maxArrayLength="100000000" maxBytesPerRead="100000000" maxNameTableCharCount="100000000"/>
     </binaryMessageEncoding>
      <netMessagingTransport  manualAddressing="false" maxBufferPoolSize="100000" maxReceivedMessageSize="100000000">
        <transportSettings batchFlushInterval="00:00:00"/>
      </netMessagingTransport>
    </binding>
  </customBinding> 

カスタム バインディングの使用方法の詳細については、この投稿を参照してください。

于 2013-08-01T10:58:05.243 に答える
0

現在、NetMessagingBinding では、XML 構成を使用して MaxStringContentLenght を変更することはできません。

私にとってうまくいった解決策は、IDispatchMessageFormatterインターフェイスを実装して、メッセージ フォーマッタの動作拡張を作成することでした。

拡張機能は、次のいずれかで使用できます。

  • どの操作コントラクトがメッセージ フォーマッタの動作を使用するかを識別するためにコードで使用できる属性を作成する

    public class MessageFormatterExtensionBehaviorAttribute : 
       Attribute, IOperationBehavior
    {
    
      (...)
    
    public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
    {
        dispatchOperation.Formatter = new MessageFormatterExtension();
    }
    
    (...)
    
    }
    
  • カスタム動作を公開する構成要素を作成します。

于 2013-06-10T09:52:00.457 に答える
0

エラーから、これは Service Bus ではなく WCF レベルのエラーのようです。MaxMessageSize を上げようとしましたか? このスレッドには情報がありますが、基本的には、web.config のバインドの構成で次のような設定を行う必要があります。

     <binding name="yourBinding"
             maxReceivedMessageSize="10000000" 
             maxBufferSize="10000000"
             maxBufferPoolSize="10000000">
        <readerQuotas maxDepth="32" 
             maxArrayLength="100000000"
             maxStringContentLength="100000000"/>
    </binding>
于 2013-06-04T20:39:11.553 に答える