I know it's possible to add a header to a WCF request, like described here: How to add HTTP Header to SOAP Client
Service1Client serviceClient = new Service1Client();
using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)serviceClient.InnerChannel))
{
System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add("AdminGUID", "someGUID");
serviceClient.GetData();
}
I have a use case, where I need to add such a header to all outgoing requests, and I would like to avoid wrapping every single WCF service method call in a using statement.
Is there a way to configure the ServiceSoapClient to add these headers to all requests?
Or maybe is there a way to generate a child class from the service reference, that would wrap all calls to base class, without doing it manually? A macro would be handy here...