我正在使用 webHttpBinding 来公开 wcf 服务并返回 JSON 格式,我想在标头中进行一些安全身份验证,例如:
CustomerServiceClient client = new CustomerServiceClient();
using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
{
MessageHeader header = MessageHeader.CreateHeader("username", "http://tempuri.org", "testuser");
OperationContext.Current.OutgoingMessageHeaders.Add(header);
}
但我收到此错误消息:信封版本“EnvelopeNone (http://schemas.microsoft.com/ws/2005/05/envelope/none)”不支持添加消息头。
我谷歌了很长时间,但对我来说没有结果。
谢谢。