C# – WCF – configuration for custom binding

cc#-4.0wcf

I am trying to plugin a custom message encoder into the WCF pipeline through configuration. Earlier I was using the out of box "NetTcpBinding" for which my configuration file looked like

<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.

How to pass on the other information?

Thanks

Best Answer

Try adding a HttpTransportBindingElement. I think that will do the trick for you. Here is the link.

Related Topic