During the last posts we talked a lot about behaviors, but only in passing about bindings.
Bindings for policies relying on behaviors.
Our policy was defined in a way that extended the behavior of clients and services. Still we needed a BindingElement for exporting the policy assertion (and we took a shortcut on top of that). However, in order to use BindingElements you need a custom binding (no WsHttpBinding or other). Should you have another binding already in place, you need to change this – which however implies an unnecessarily complicated translation from other bindings to custom bindings. Yaron’s converter might help with this.
Policies relying on bindings.
Some demands do not affect the behavior of the service, but the message content on the wire. Examples include custom encodings, compression, or similar requirements. These demands should be realized by bindings instead of behaviors. Unfortunately this requires quite a bit more effort.
Providing a custom binding implementing the demand is probably the simple part. On top of that, one needs to customize the building of the channel. Replacing an existing binding, e.g. the message encoding stage, is shown in WCF Extensibility – Policy Import / Export Extensions. It gets even more complicated if an additional binding needs to be inserted. The SDK sample Custom Message Interceptor shows how this can be accomplished. Carlos explains it a bit more in detail in his posts WCF Extensibility – Channels and WCF Extensibility – Channels (server side).
As a personal note…
I cannot see any reason why the above tasks have to be so complicated or why they require so much effort. Specialized bindings, such as WsHttpBinding build internally on binding elements, so there should be a straight forward translation between bindings. Similarly WCF channels are a simple pipeline, which is a pattern that is common enough. Why are the stages nearly set in stone, why does it take so much effort to introduce extensions?
WCF is at times rather complex due to the complexity of the protocols that need to be configured. Adding unnecessarily (I think) to this complexity is just annoying.
Just my 0,02€.
That’s all for now folks,
AJ.NET
Leave a Reply