【发布时间】:2021-05-10 11:38:29
【问题描述】:
我有一个应用程序可以为给定的 WSDL 地址即时编译服务引用程序集:
-
使用 System.Net.WebClient 以 OpenRead 目标服务作为 Stream
-
将 WSDL 描述为代码编译单元:https://docs.microsoft.com/en-us/dotnet/api/system.web.services.description.servicedescriptionimporter
ServiceDescription 描述 = ServiceDescription.Read(stream);
然后,该程序集中的所有服务类型都有可以设置的 Credentials(类型 ICredentials),例如
someService.GetType().GetProperty("Credentials").SetValue(someService, new NetworkCredential(userName, password));
在基本身份验证场景中按预期工作。
我现在需要开始支持 Bearer authentication(不确定术语是否正确),即在这些服务的请求级别,具有 Authorization 标头,其值为 不记名
但是,我无法使用 OperationContextScope 将标头 (How to add HTTP Header to SOAP Client) 注入到我的服务引用调用中,因为我编译的类型不包含 InnerChannel。
我认为在底层 NetworkCredentials 会产生像 Authorization: Basic
【问题讨论】:
标签: c# jwt wsdl credentials