public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { LogManager.GetLogger().Debug("AfterReceiveRequest"); MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue); request = buffer.CreateMessage(); // System.ServiceModel.Channels.Message messageCopy = buffer.CreateMessage(); // Read the custom context data from the headers ServiceHeader customData = CustomHeader.ReadHeader(request); // Add an extension to the current operation context so // that our custom context can be easily accessed anywhere. ServerContext customContext = new ServerContext(); if (customData != null) { customContext.UserID = customData.UserID; customContext.KerberosID = customData.KerberosID; customContext.SiteminderToken = customData.SiteminderToken; customContext.UserHeaderToken = customData.UserToken; customContext.VerificationCode = customData.VerificationCode; } if (OperationContext.Current.IncomingMessageProperties.ContainsKey("CurrentContext")) { OperationContext.Current.IncomingMessageProperties.Remove("CurrentContext"); } OperationContext.Current.IncomingMessageProperties.Add( "CurrentContext", customContext); //***************** object result; request.Properties.TryGetValue(TextOrMtomEncodingBindingElement.IsIncomingMessageMtomPropertyName, out result); return(result); }
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel) { LogManager.GetLogger().Debug("BeforeSendRequest"); MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue); request = buffer.CreateMessage(); ServiceHeader customData = new ServiceHeader(); customData.KerberosID = ClientContextBucket.KerberosID; customData.SiteminderToken = ClientContextBucket.SiteminderToken; customData.UserID = ClientContextBucket.UserID; customData.UserToken = ClientContextBucket.UserHeaderToken; customData.VerificationCode = ClientContextBucket.VerificationCode; CustomHeader header = new CustomHeader(customData); // Add the custom header to the request. request.Headers.Add(header); return(null); }