如何为WCF服务编写拦截器

时间:2013-06-05 10:28:31

标签: wcf web-services request

我有一个带有basicHttpBinding的WCF服务。我想为服务中的每个方法调用编写拦截器来做一些日志记录。 我想仅为某些字段方法添加此拦截器。

我在WCF中很新。任何帮助表示赞赏。

感谢。

1 个答案:

答案 0 :(得分:1)

您需要实施IDispatchMessageInspector - 您可以get the invoked method by looking at the OperationContext,然后您可以决定是否要处理方法调用。

然后,您必须实现通常的WCF管道,ServiceBehavior和BehaviorExtension,就像在doc页面中一样。

相关问题