I would like to an HTTP header to my WCF SOAP Service. My end goal is to send API keys through this HTTP header.
Below is my code:
[ServiceBehavior(Namespace = "http://****.com/**/1.1")] public class MyWcfSvc : IMyVerify { const int MaxResponseSize = 0xffff; // 64K max size - Normally it will be MUCH smaller than this private static readonly NLogLogger Logger; static MyWcfSvc() { Logger = new NLogLogger(); // Add an HTTP Header to an outgoing request HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers["User-Auth"] = "MyHttpHeaderValue"; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; } } I do not see User-Auth header under HTTP request headers.
I also tried with another way.
public AnalyzeResponse Analyze(AnalyzeRequest analyzeRequest) { HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers["User-Auth"] = "MyHttpHeaderValue"; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; . . . Rest of the service implementation . . . } But, still, I don't see any HTTP header information with the request message. I am using SOAP UI to send the requests and to view the responses.
How should I go about this? Am I suppose to make changes to the Service related to class? Or I need to make some changes to web.config file?