I'm trying to attach an api key to the OperationContext outgoing message header as follows:
public static void AddApikeyToHeader(string apikey, IContextChannel channel, string address) { using (OperationContextScope scope = new OperationContextScope(channel)) { MessageHeader header = MessageHeader.CreateHeader("apikey", address, apikey); OperationContext.Current.OutgoingMessageHeaders.Add(header); } } but then I have no idea how to retrieve the header on the server side. I'm using a Service authorisation manager and I get the current operating context and try to retrieve the header like this:
public string GetApiKey(OperationContext operationContext) { var request = operationContext.RequestContext.RequestMessage; var prop = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name]; return prop.Headers["apikey"]; } but there is no apikey header attached there. Also, on debugging when I inspect the operationContext I cant seem to see my apikey header anywhere. Can anyone see where I'm going wrong?