Two weeks before submitting the final copy of my latest book, I reran all my chapter demonstrations that had been built during the year. Since many demos were written with beta versions of products, I figured I should be smart and verify that everything was fine with the most recent releases. But alas, everything was not fine.
The demo for my Chapter 8 on content based routing (which can mostly be read online at the Packt site) all of a sudden wouldn’t run. This demo uses the WCF Routing Service to call Workflow Services which sit in front of LOB system services. When I ran my demo using the final version of Windows Server AppFabric as the host, I got this dumpster-fire of an error from the Routing Service:
An unexpected failure occurred. Applications should not attempt to handle this error. For diagnostic purposes, this English message is associated with the failure: ‘Shouldn’t allocate SessionChannels if session-less and impersonating’.
Now, anytime that a framework error returns zero results from various search engines, you KNOW you are in faaaantastic shape. After spending hours fiddling with directory permissions, IIS/AppFabric settings and consulting a shaman, I decided to switch WCF bindings and see if that helped. Workflow Services don’t make binding changes particularly easy (from what I’ve seen; your mileage may vary), so I used a protocol mapping section to flip the default Workflow Service binding from BasicHttpBinding to WsHttpBinding and then also switched the Routing Service to use WsHttpBinding.
<protocolMapping> <add scheme="http" binding="wsHttpBinding"/> </protocolMapping>
Voila! It worked. So, I confidently (and erroneously) added a small block of text in the book chapter telling you that problems with the Routing Service and BasicHttp can be avoided by doing the protocol mapping and using WsHttp in the Routing Service. I was wrong.
Once the book went to press, I had some time to rebuild a similar solution from scratch using the BasicHttpBinding. Naturally, it worked perfectly fine. So, I went line by line through both solutions and discovered that the Routing Service in my book demo had the following line in the web.config file:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
If I removed the aspNetCompatibilityEnabled property, my solution worked fine. You can read more about this particular setting here. What is interesting is that if I purposely ADD this element to the configuration files of the Workflow Services, I don’t get any errors. It only seems to cause grief for the Routing Service. I’m not sure how it got into my configuration file in the first place, but I’m reviewing security footage to see if the dog is to blame. Still not sure why this worked with the beta of Server AppFabric though.
So, you’d never hit the above error if you used WsHttpBindings in your Workflow Services and upstream Routing Service, but if you do choose to use the BasicHttpBinding binding for your Routing Service, for all that is holy, please remove that configuration setting.