c# - 如何在 Api Management Soap 中通过 URL 添加 header ?

标签 c# azure asp.net-web-api wsdl azure-api-management

我正在使用 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/

相关文章:

c# - 流畅的验证不适用于列表对象

c# - WSDL 与 Windows Phone 8 兼容吗?

c# - DotNetOpenAuth:模拟 ClaimsResponse

c# - 类及其嵌套类的一个构造函数

iis - 我可以交叉开发 IIS 和 Azure 的应用程序吗?

c# - 单元测试 C# [TestInitialize]

http - 使用 Webapi 将图像渲染到浏览器

c# - 无法使用 Linq 查询删除 XmlElement

azure - 如何在Azure容器服务中获取Swarm代理负载均衡器的URL

Azure QnA 在 Facebook 聊天中显示 URL