简体   繁体   English

WCF-自定义绑定的配置

[英]WCF - configuration for custom binding

I am trying to plugin a custom message encoder into the WCF pipeline through configuration. 我正在尝试通过配置将自定义消息编码器插入WCF管道。 Earlier I was using the out of box "NetTcpBinding" for which my configuration file looked like 之前我使用的是现成的“ 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>

For plugging in the custom encoder I tried to following custom binding configuration 为了插入自定义编码器,我尝试遵循自定义绑定配置

<bindings>
      <customBinding>
          <binding name="compactBinding">
              <compactMessageEncoding>
                          <binaryMessageEncoding/>
              </compactMessageEncoding>
              <tcpTransport />
          </binding>
      </customBinding>
  </bindings>

It works fine. 工作正常。 But I still want my earlier settings like maxBufferSize, maxReceivedMessageSize, maxBufferPoolSize etc. It seems the <binding> element under <customBinding> only has closeTimeout, openTimeout, receiveTimeout, sendTimeout. 但我还是希望我早像MAXBUFFERSIZE,maxReceivedMessageSize,maxBufferPoolSize等设置,它似乎<binding>元素下<customBinding>只有closeTimeout,openTimeout,receiveTimeout,的SendTimeout。

How to pass on the other information? 如何传递其他信息?

Thanks 谢谢

Try adding a HttpTransportBindingElement. 尝试添加HttpTransportBindingElement。 I think that will do the trick for you. 我认为这将为您解决问题。 Here is the link . 这是链接

Try adding the configuration in code like this: 尝试在如下代码中添加配置:

((CustomBinding)servicio.Endpoint.Binding).Elements.Find<TransportBindingElement>().MaxReceivedMessageSize = int.MaxValue;

And also add a readerQuotas to the web.config: 并将一个readerQuotas添加到web.config中:

<readerQuotas maxDepth="90000" maxStringContentLength="2147483647"
                         maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<customBinding>
      <binding>
       ...
        <tcpTransport listenBacklog ="100" maxBufferPoolSize ="524288" maxBufferSize ="2147483647" maxReceivedMessageSize ="2147483647"/>
       ...
      </binding>
</customBinding>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM