I am consuming a WCF service that requires headers from a .NET 2 website. How can I programmatically add the headers to the messages?
问题 I have a WCF service that uses a custom instance provider (implements IInstanceProvider) for which the GetInstance method expects a message that contains a few headers, like this: public object GetInstance(InstanceContext instanceContext, Message message) { string token = null; if (message != null) { token = message.Headers.GetHeader<string>("Token", "urn:userinfo"); } Bootstrapper bootstrapper = new Bootstrapper(); bootstrapper.InitialiseSession(token); return new MyServiceHost(bootstrapper