我正在尝试通过配置将自定义消息编码器插入到WCF管道中。之前我使用的是“NetTcpBinding”框,我的配置文件看起来像是
<bindings>
<netTcpBinding>
<binding name="DefaultNetTcpBinding"
maxBufferSize="26214400"
maxReceivedMessageSize="26214400"
maxBufferPoolSize="26214400"
listenBacklog="1000"
maxConnections="1000"
closeTimeout="00:01:00"
openTimeout="00:10:00"
receiveTimeout="00:01:30"
sendTimeout="00:01:00">
<security mode="None"/>
<reliableSession ordered="true" inactivityTimeout="00:01:30" enabled="true"/>
</binding>
</netTcpBinding>
</bindings>
为了插入自定义编码器,我试图遵循自定义绑定配置
<bindings>
<customBinding>
<binding name="compactBinding">
<compactMessageEncoding>
<binaryMessageEncoding/>
</compactMessageEncoding>
<tcpTransport />
</binding>
</customBinding>
</bindings>
工作正常。但我仍然想要我的早期设置,如maxBufferSize,maxReceivedMessageSize,maxBufferPoolSize等。<binding>
下的<customBinding>
元素似乎只有closeTimeout,openTimeout,receiveTimeout,sendTimeout。
如何传递其他信息?
由于
答案 0 :(得分:6)
尝试添加HttpTransportBindingElement。我想这对你来说会有所帮助。这是link。
答案 1 :(得分:1)
<customBinding>
<binding>
...
<tcpTransport listenBacklog ="100" maxBufferPoolSize ="524288" maxBufferSize ="2147483647" maxReceivedMessageSize ="2147483647"/>
...
</binding>
</customBinding>
答案 2 :(得分:0)
尝试在以下代码中添加配置:
((CustomBinding)servicio.Endpoint.Binding).Elements.Find<TransportBindingElement>().MaxReceivedMessageSize = int.MaxValue;
还要在web.config中添加一个readerQuotas:
<readerQuotas maxDepth="90000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />