views:

168

answers:

1

I'm implementing localization in my WCF application according to http://www.codeproject.com/KB/WCF/WSI18N.aspx and some other articles. Basicly I'm attaching a message header with current culture info on client (using IClientMessageInspector implementation) and then applying the culture info on current thread on server side (using ICallContextInitializer implementation). The probem I'm currently facing is that my implementation of ICallContextInitializer isn't probably the best place to actually change the Thread.CurrentThread.CurrentCulture according to message header, because resetting the thread's culture in AfterInvoke() occurs before other things which should still be in localized context. Currently I've problem with IErrorHandler implementation - it's called after ICallContextInitializer.AfterInvoke() so the thread is already reset back to default culture and so I can't work with localized resources in my IErrorHandler.

Is there any better extension place than ICallContextInitializer I could use for localization based on message header? Or better - is there any article describing execution sequence in WCF? I'd like to understand the sequence in which are different extension points processed...


The problem is solved, but I'd like to get more information about WCF internal execution sequence etc - any tips what to read on this topic?

+1  A: 

The exact way of how the dispatcher behaves isn't really very documented (like much in WCF). Personally, I'd give a try using an IDispatchMessageInspector instead, since that also runs after a fault message is generated and returned to the user, it might be more likely to allow your IErrorHandler to be run in the right context

tomasr
I reimplemented the problem using IDispatchMessageInspector and it really started to work as I needed - IErrorHandler.ProvideFault gets called BEFORE current thread culture is reset back in IDispatchMessageInspector.BeforeSendReply. Thanks.I'd like to get more information on WCF interactions/execution sequence like this anyway to understand WCF more in depth - will appreciate any tip what to read on this topic...
Buthrakaur