如何在WCF消息检查器中获取调用的操作名称 [英] How do i get the invoked operation name within a WCF Message Inspector
本文介绍了如何在WCF消息检查器中获取调用的操作名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在WCF中做一个消息检查器:
I'm doing a message inspector in WCF:
public class LogMessageInspector :
IDispatchMessageInspector, IClientMessageInspector
实现方法:
public object AfterReceiveRequest(ref Message request,
IClientChannel channel, InstanceContext instanceContext)
我可以通过以下方式获取被调用服务的名称:
I can get the name of the invoked service with:
instanceContext.GetServiceInstance().GetType().Name
但是如何获取被调用操作的名称?
But how do I get the name of the invoked operation?
推荐答案
这不是很漂亮,但这是我为获取操作名称所做的:
It's not pretty, but this is what I did to get the operation name:
var action = OperationContext.Current.IncomingMessageHeaders.Action;
var operationName = action.Substring(action.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1);
这篇关于如何在WCF消息检查器中获取调用的操作名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文