I'm trying to get WCF config files better so I can more-easily work on more-complex scenarios. As is usually the case, I'm revisiting my understanding of the basics. So this brings up the question, What is the difference between a Binding configuration and a Behavior? I'm not asking about what is a binding (i.e. netTcpBinding
, etc.). I get that.
So let's say I have a config file with multiple configurations for that single binding:
<netTcpBinding>
<binding name="LargeMessages" maxBufferPoolSize="5242880" maxBufferSize="5242880" maxReceivedMessageSize="5242880">
<readerQuotas maxDepth="256" maxStringContentLength="16384" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None"></security>
</binding>
<binding name="LargeFiles" maxBufferPoolSize="15728640" maxBufferSize="15728640" maxReceivedMessageSize="15728640">
<!-- 15MB max size -->
<readerQuotas maxDepth="256" maxStringContentLength="15728640" maxArrayLength="15728640" maxBytesPerRead="204800" maxNameTableCharCount="15728640" />
<security mode="None"></security>
</binding>
<binding name="LargeStrings" maxBufferPoolSize="524288" maxBufferSize="524288" maxReceivedMessageSize="524288">
<!-- 0.5MB max size -->
<readerQuotas maxDepth="256" maxStringContentLength="524288" maxArrayLength="524288" maxBytesPerRead="204800" maxNameTableCharCount="524288" />
<security mode="None"></security>
</binding>
</netTcpBinding>
In this scenario, I'm calling LargeMessages
, LargeFiles
, and LargeStrings
"Binding Configurations".
Now that I have that config, I can also have multiple Behaviors, where one might look like this:
<behavior name="DefaultServiceBehavior">
<serviceCredentials>
<serviceCertificate findValue="1234123412341234123412341234"
x509FindType="FindByThumbprint" />
</serviceCredentials>
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
In this case, DefaultServiceBehavior
is a behavior.
So a different way to ask my question is, Why can't my Binding Configuration contain all of my settings that my Behavior specifies? Or vice versa? At a basic and high level, why do we have both sets of settings? It seems both can very significantly affect my transport configuration or my message configuration. I just don't see the logic for the separation of settings.
In technical terms:
In layman's terms:
Conclusion, your services should speak the appropriate language (binding) and act (behaviour) as they are supposed to otherwise clients might have a hard time trying to communicate with them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With