【发布时间】:2022-01-19 00:36:36
【问题描述】:
我正在尝试使用 WSDL Web 服务,它需要在标头中发送访问令牌。但是,我不断收到 401 错误,我不确定我是否正确注入了令牌。
这是代码的sn-p:
var client = new WsldClient();
var operationContext = new OperationContext(client.InnerChannel);
using (new OperationContextScope(operationContext))
{
var httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Bearer " + accessToken
operationContext.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
client.SomeMethod();
}
这会返回 401 错误。
【问题讨论】:
标签: c# web-services wcf wsdl access-token