You could try to implement an IServiceBehavior
and an IParameterInspector
class, which will handle the logging.
IServiceBehavior
The ApplyDispatchBehavior
is the most important method to implement:
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
{
foreach (var endpoint in dispatcher.Endpoints)
{
foreach (var dispatchOperation in endpoint.DispatchRuntime.Operations)
{
dispatchOperation.ParameterInspectors.Add(new LoggingParameterInspector(/*reference to your logger*/));
}
}
}
}
You have to apply this ServiceBehavior
to your service, either by making it an Attribute
on your service implementation class, or by adding it to the definition at startup time.
IParameterInspector
this interface has two methods: BeforeCall
and AfterCall
. In the implementation of these methods you can access the operation name and the inputs given to the method. This allows you to create a clean and simple trace of all calls to the service.
Although I'm not sure how to exactly log the content of the SOAP messages, this method can provide you with a lot of extra info, expecially if you implement a timed logging.