1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
class DispatchMessageInspector : IDispatchMessageInspector
{
#region IDispatchMessageInspector Members
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request,
System.ServiceModel.IClientChannel channel,
System.ServiceModel.InstanceContext instanceContext)
{
//Ici tu peux logger les appels en interceptant les headers
}
public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
if (ServiceContext.Current == null) { return; }
IList<ServerNotification> notifications= ServiceContext.Current.GetPendingNotifications();
if (notifications!=null && notifications.Count!=0)
{
MessageHeader h = MessageHeader.CreateHeader(Constants.MessageHeaderNotificationName, Constants.MessageHeaderNotificationNameSpace, notifications);
reply.Headers.Add(h);
}
OperationContext.Current.Extensions.Remove(ServiceContext.Current);
}
#endregion
} |
Partager