我正在使用 Azure API Management Soap 通过 URL(ENDpoint) 传递 它具有用于身份验证的订阅 key 。
但是当我添加 wsdl Web 端点时,只有基地址,没有 header 。在网络服务调用之后我收到错误:
{"The HTTP request is unauthorized with client authentication scheme 'Anonymous'.
The authentication header received from the server was 'Key realm=\"https:\url\",name=\"Key\",type=\"header\"'."}
我想我错过了传递 header 。
如何传递 header 来调用 Web api 端点? 我们不能在 web.config 中提及它。
最佳答案
实际上您不应该使用订阅 key 进行身份验证。
我猜 APIM 会默认转发所有 header 。但如果没有,你可以尝试这样的事情:
<set-header name="Ocp-Apim-Subscription-Key" exists-action="override">
<value>@(context.Request.Headers.GetValueOrDefault("Ocp-Apim-Subscription-Key", ""))</value>
</set-header>
关于c# - 如何在 Api Management Soap 中通过 URL 添加 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40888184/