I have a question with regards to WCF client channel lifetime while using Message security, but first, a few notes on my company's setup and guidelines:
- Our client-server applications are solely for intranet use
- Our clients are WPF applications
- Our company's guidelines for WCF usage are:
- Use wsHttpBinding
- Use Message Security
- Service InstanceMode: PerCall
- Service ConcurrencyMode: Multiple
It is the first time I have to use message security on an intranet setup. Here's how I typically use my client channels to limit the amount of resources kept on the client and server and literally just to keep things simple:
- Instantiate + open channel (with ChannelFactory)
- Make the WCF call
- Close / dispose the channel asap
While monitoring this strategy with Fiddler 2, I noticed that because of Message Security, a single WCF call ended up causing 5 round-trips to my service:
- 3 initial round-trips for handshaking
- 1 round-trip for the actual WCF call
- 1 call to close the session (since I am using PerCall, I am assuming this is more a security session at the IIS level)
If I were to turn off Message Security, as one would expect, one WCF ended up being... A single round-trip.
As of now, I must use Message Security because that's our guideline. With this in mind and knowing that we make hundreds of WCF calls from each client WPF app a session, would you therefore advise to open the client channel and keep it open for re-use instead of disposing of it every time?