WCF Service Wrapper

What is best for creating a wrapper to call a WCF service? I think it is necessary to keep track of all the calls in the same place, I think using this type of code is the right idea?

RetType t = ServiceExecutionContext<IServiceChanel>.Execute(s=>s.GetServiceMethod()); 


What shell do you use in your corporate applications?
Thank you very much!

+2
source share
2 answers

WCF has a model that allows you to be in the service call chain. I would use this instead of trying to wrap every utility call if all you are trying to do is some registration (which WCF already does very well if you include diagnostics in the configuration file) and things like that around your service calls.

Here is a good MSDN article on how to create custom behaviors for WCF services.

+6
source

If you need, write your own Message Inspector .

WCF also has journaling . By default, you can easily write the file to the System.Diagnostics.XmlWriterTraceListener file, however, if you need to write a log elsewhere (say, in the database), you can write your own trace listener .

I would recommend this approach over the message inspector ... message inspectors are too easy to write incorrectly and cut back on performance without knowing what you are doing.

+1
source

Source: https://habr.com/ru/post/1387403/


All Articles