/// <summary>
        /// Called after an inbound message has been received but before the message is dispatched to the intended operation.
        /// </summary>
        /// <param name="request">The request message.</param>
        /// <param name="channel">The incoming channel.</param>
        /// <param name="instanceContext">The current service instance.</param>
        /// <returns>
        /// The object used to correlate state. This object is passed back in the <see cref="M:System.ServiceModel.Dispatcher.IDispatchMessageInspector.BeforeSendReply(System.ServiceModel.Channels.Message@,System.Object)"/> method.
        /// </returns>
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            var ctxt = MessageInspectorHelper.DecodeWulkaContext(ref request);

            if (channel != null)
            {
                var listenUri = channel.LocalAddress.ToString().ToLower();
                if (listenUri.Contains("/mex"))
                {
                    return(null);
                }
                //_logger.Debug("Received message on {0}", listenUri);
            }
            if (IsValidatedSession(ctxt))
            {
                var usr  = ctxt[WulkaContextKey.UserName];
                var sess = ctxt[WulkaContextKey.SessionId];
                var app  = ctxt[WulkaContextKey.ServiceCode];
                if (!CheckSession(usr, sess))
                {
                    _logger.Info("User {0} could not be validated against session {1}", usr, sess);
                }
            }
            WulkaContext.Current = ctxt;
            return(null);
        }
 /// <summary>
 /// Called after the operation has returned but before the reply message is sent.
 /// </summary>
 /// <param name="reply">The reply message. This value is null if the operation is one way.</param>
 /// <param name="correlationState">The correlation object returned from the <see cref="M:System.ServiceModel.Dispatcher.IDispatchMessageInspector.AfterReceiveRequest(System.ServiceModel.Channels.Message@,System.ServiceModel.IClientChannel,System.ServiceModel.InstanceContext)"/> method.</param>
 public void BeforeSendReply(ref Message reply, object correlationState)
 {
     if (WulkaContext.Current != null)
     {
         MessageInspectorHelper.EncodeWulkaContext(WulkaContext.Current, ref reply);
     }
 }
Пример #3
0
 /// <summary>
 /// Enables inspection or modification of a message before a request message is sent to a service.
 /// </summary>
 /// <param name="request">The message to be sent to the service.</param>
 /// <param name="channel">The  client object channel.</param>
 /// <returns>
 /// The object that is returned as the <paramref name="correlationState "/>argument of the <see cref="M:System.ServiceModel.Dispatcher.IClientMessageInspector.AfterReceiveReply(System.ServiceModel.Channels.Message@,System.Object)"/> method. This is null if no correlation state is used.The best practice is to make this a <see cref="T:System.Guid"/> to ensure that no two <paramref name="correlationState"/> objects are the same.
 /// </returns>
 public object BeforeSendRequest(ref Message request, IClientChannel channel)
 {
     return(MessageInspectorHelper.EncodeWulkaContext(ref request, channel));
 }
Пример #4
0
 /// <summary>
 /// Enables inspection or modification of a message after a reply message is received but prior to passing it back to the client application.
 /// </summary>
 /// <param name="reply">The message to be transformed into types and handed back to the client application.</param>
 /// <param name="correlationState">Correlation state data.</param>
 public void AfterReceiveReply(ref Message reply, object correlationState)
 {
     WulkaContext.Current = MessageInspectorHelper.DecodeWulkaContext(ref reply);
 }