开发者

How to count number of WCF calls on client?

I have a large number of different WCF client classes (inheriting from ClientBase).

I'd like to capture method name and num开发者_JAVA百科ber of times this method was called every time such client is used. This info would be used for performance tuning.

Any ideas?


You should take a look at the System.ServiceModel.Dispatcher namespace, as it provides a number of interfaces that you can use to intercept calls on the client (and server) side to perform your count.

Note that most of the methods here are operating on the Message level; WCF at a high level is ignorant of the concept of methods, it dispatches messages, receives them, and then processes them.

However, for the most part, you can figure out from the Message what the mapping should be and record that.

Once you implement the appropriate dispatcher interface, you would simply wire it up to your ClientBase<T> instances. In the dispatcher interface, make sure you have a way of holding onto the original dispatcher (if you go that route) so you can forward your calls appropriately.


Look the extensibility points defined by WCF. Carlo's did an excellent series here. Look specifically at MessageInspector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜