hg *_*lim 15 wcf wcf-extensions
我正在努力更好地了解WCF的调度过程,特别是对各种可扩展性点的影响和影响.从底部列出的网页看,一旦消息通过通道堆栈传递给调度程序,WCF将按照所述顺序执行以下操作.
我试图找到一些选项来解决我遇到的问题,我想到的一种方法是使用Message Inspector,Operation Selector,Message Formatting和Operation Invoker的组合.不幸的是,我的观察似乎表明执行的顺序如下:
我可以理解在格式化消息之前调用自定义调用者AllocateInputs()方法的细微差别,因为消息格式化部分基本上将给定消息反序列化为一组方法参数,以传递给适当的操作和调用者的AllocateInputs( )方法指定预期的参数数量.
抛出我的部分是Message Inspector和Operation Selector之间的序列反转.对于我来说,消息检查器首先运行,因为它们对消息起作用,而操作选择器确定消息所针对的服务操作,这听起来合乎逻辑.
问题:
参考页:
扩展WCF以支持自定义数据格式 - Zulfiqar的博客
使用自定义行为扩展WCF - MSDN服务站2007年12月
消息流拦截点 - Nicholas Allen的Indigo博客
注意:对于不提供链接,我道歉,因为我还是菜鸟,所以不能有多个链接.=)
要确定代码执行的实际顺序,我建议启用WCF跟踪并查看生成的跟踪日志.这可以通过将其添加到配置文件来启用:
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
Run Code Online (Sandbox Code Playgroud)
至于WCF中的可扩展性点,Carlos Figueira(微软WCF的工程师之一)有一篇文章详细介绍了WCF中的所有扩展点(http://blogs.msdn.com/b/carlosfigueira/archive/ 2011/03/14/wcf-extensibility.aspx).
在本文的WCF运行时部分中,排序如下:
1.2. WCF Runtime
1.2.1. Message interception
1.2.1.1. I[Client/Dispatch]MessageInspector
1.2.1.2. IParameterInspector
1.2.2. Mapping between message and operation parameter
1.2.2.1. I[Client/Dispatch]MessageFormatter
1.2.3. Mapping between message and CLR operations
1.2.3.1. I[Client/Dispatch]OperationSelector
1.2.3.2. IOperationInvoker
1.2.4. Instance creation
1.2.4.1. IInstanceProvider
1.2.4.2. IInstanceContextProvider
1.2.5. Error handling
1.2.5.1. IErrorHandler
1.2.6. Others
1.2.6.1. ICallContextInitializer
1.2.6.2. IChannelInitializer
1.2.6.3. IInteractiveChannelInitializer
Run Code Online (Sandbox Code Playgroud)
我认为在两者之间WCF中的操作顺序应该变得清晰.