使用 Header 在 Visual Studio 中添加 Web 引用

Add Web Reference in Visual Studio with Header

让我描述一下我的问题。我正在尝试添加对 Magento 2.x SOAP API.

的 Web 引用

在 Magento 1.x 中,我们可以只使用给定的肥皂服务 URL 并使用 Visual Studio in-built UI 生成 类工具 "Add Service Reference > Advanced > Web Reference"

但是在 Magento 2.x 中 url 需要 "Authorization" header 到 return WSDL。

我尝试使用 Postman 使用 header 命中 API,它 return WSDL 没问题。但是没有选项可以在 Visual Studio "Add Web Reference" 对话框中包含 headers。

谁能指出我正确的方向?

对于那些偶然发现这个的人。 我按照@Filburt 的评论进行了以下操作。


使用 Rest 和 Postman GET 生成了管理令牌(参考 Magento documentation

  1. Header : Content-Type - application/json
  2. Body : {"username" : "my username","password" : "my password"}

使用 Postman GET 请求点击我需要的个人 Magento SOAP APIs

使用 Postman in-built 授权 > Bearer 令牌:从上一步获得价值

然后使用 .wsdl 扩展名

在本地保存结果 XML

在 Visual Studio 中使用了 In-built "Add Service Reference" UI 并导入了 wsdl 文件。

已成功生成所有服务。