如何在 WCF 消息检查器中获取调用的操作名称
我正在 WCF 中做一个消息检查器:
public class LogMessageInspector :
IDispatchMessageInspector, IClientMessageInspector
它实现了以下方法:
public object AfterReceiveRequest(ref Message request,
IClientChannel channel, InstanceContext instanceContext)
我可以通过以下方式获取调用的服务的名称:
instanceContext.GetServiceInstance().GetType().Name
但是如何获取调用的操作的名称?
I'm doing a message inspector in WCF:
public class LogMessageInspector :
IDispatchMessageInspector, IClientMessageInspector
which implements the method:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这并不漂亮,但这就是我为获取操作名称所做的操作:
It's not pretty, but this is what I did to get the operation name:
此方法与此处介绍的其他方法类似,但使用
Path.GetFileName
:此方法的返回值和
path
字符串的格式在这种情况下工作得非常和谐:This approach is similar to others presented here, but uses
Path.GetFileName
:The return value of this method and the format of the
path
string work quite harmoniously in this scenario:聚会有点晚了,但我必须比这个问题的现有答案更深入地挖掘,因为它们似乎涉及获取操作名称而不是操作名称。 (它们通常是相同的,因此获取操作名称实际上就是获取操作名称。)
Microsoft 的 Application Insights SDK Labs 的 WCF 库使得 此共同努力:
Little late to the party but I had to dig a little deeper than existing answers on this question because they seem to involve getting the action name and not the operation name. (Frequently they are the same so getting the action name does, in fact, get the operation name.)
Microsoft's Application Insights SDK Labs' WCF library makes this concerted effort: