导入 SOAP API 并将其转换为 RESTImport a SOAP API and convert to REST

本文介绍如何导入 SOAP API 并将其转换为 REST。This article shows how to import a SOAP API and convert it to REST. 此外,介绍如何测试 APIM API。The article also shows how to test the APIM API.

在本文中,学习如何:In this article, you learn how to:

  • 导入 SOAP API 并将其转换为 RESTImport a SOAP API and convert to REST
  • 在 Azure 门户中测试 APITest the API in the Azure portal
  • 在开发人员门户中测试 APITest the API in the Developer portal

必备条件Prerequisites

完成以下快速入门:创建 Azure API 管理实例Complete the following quickstart: Create an Azure API Management instance

转到你的 API 管理实例Go to your API Management instance

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 选择“所有服务”。Select All services.

  3. 在搜索框中输入 apiIn the search box, enter api.

  4. 在搜索结果中,选择“API 管理服务”。In the search results, select API Management services.

  5. 选择自己的 API 管理服务实例。Select your API Management service instance.

提示

若要将 API 管理添加到 Azure 门户中的收藏夹,请选择星形。To add API Management to your favorites in the Azure portal, select the star.

API 管理图标The API Management icon ((API 管理图标)现在显示在门户的左侧菜单中。) now appears in the left menu in the portal.

导入和发布后端 API Import and publish a back-end API

  1. 在“API 管理”下面选择“API”。 Select APIs from under API MANAGEMENT.

  2. 从“添加新的 API”列表中选择“WSDL” 。Select WSDL from the Add a new API list.

    SOAP API

  3. 在“WSDL 规范”,输入要将 SOAP API 放到的 URL。 In the WSDL specification, enter the URL to where your SOAP API resides.

  4. 单击“SOAP 到 REST”单选按钮。 Click SOAP to REST radio button. 单击此选项后,APIM 会尝试在 XML 与 JSON 之间进行自动转换。When this option is clicked, APIM attempts to make an automatic transformation between XML and JSON. 在这种情况下,使用者应以 Restful API 的形式调用该 API,这会返回 JSON API。In this case consumers should be calling the API as a restful API, which returns JSON. APIM 将每个请求转换为 SOAP 调用。APIM is converting each request into a SOAP call.

    SOAP 到 REST

  5. 按 Tab 键。Press tab.

    以下字段中填充了来自 SOAP API 的信息:显示名称、名称、说明。The following fields get filled up with the info from the SOAP API: Display name, Name, Description.

  6. 添加 API URL 后缀。Add an API URL suffix. 后缀是用于在该 APIM 实例中标识此特定 API 的名称。The suffix is a name that identifies this specific API in this APIM instance. 它在此 APIM 实例中必须唯一。It has to be unique in this APIM instance.

  7. 通过关联 API 与产品来发布 API。Publish the API by associating the API with a product. 本例中使用了“无限制”产品 。In this case, the "Unlimited" product is used. 如果想要发布 API 并使其对开发人员可用,请将其添加到产品中。If you want for the API to be published and be available to developers, add it to a product. 可在 API 创建期间执行此操作,或稍后进行设置。You can do it during API creation or set it later.

    产品是一个或多个 API 的关联。Products are associations of one or more APIs. 可以包含多个 API,并通过开发人员门户将其提供给开发人员。You can include a number of APIs and offer them to developers through the developer portal. 开发人员必须先订阅产品才能访问 API。Developers must first subscribe to a product to get access to the API. 订阅时,他们会得到一个订阅密钥,此密钥对该产品中的任何 API 都有效。When they subscribe, they get a subscription key that is good for any API in that product. 如果创建了 APIM 实例,那么你已是管理员,因此默认情况下订阅了每个产品。If you created the APIM instance, you are an administrator already, so you are subscribed to every product by default.

    默认情况下,每个 API 管理实例附带两个示例产品:By default, each API Management instance comes with two sample products:

    • 入门Starter
    • 不受限制Unlimited
  8. 选择“创建” 。Select Create.

在 Azure 门户中测试新的 APITest the new API in the Azure portal

可直接从 Azure 门户调用操作,这样可以方便地查看和测试 API 的操作。Operations can be called directly from the Azure portal, which provides a convenient way to view and test the operations of an API.

  1. 选择上一步中创建的 API。Select the API you created in the previous step.

  2. 按“测试”选项卡 。Press the Test tab.

  3. 选择某个操作。Select some operation.

    该页将显示查询参数的字段和标头的字段。The page displays fields for query parameters and fields for the headers. 其中一个标头是“Ocp-Apim-Subscription-Key”,用于提供和此 API 关联的产品订阅密钥。One of the headers is "Ocp-Apim-Subscription-Key", for the subscription key of the product that is associated with this API. 如果创建了 APIM 实例,那么你已是管理员,因此会自动填充该密钥。If you created the APIM instance, you are an administrator already, so the key is filled in automatically.

  4. 按“发送”。 Press Send.

    后端以“200 正常”和某些数据做出响应 。Backend responds with 200 OK and some data.

追加其他 APIAppend other APIs

API 可以包含由其他服务公开的 API,这些服务包括 OpenAPI 规范、SOAP API、Azure 应用服务的 API 应用功能、Azure Function App、Azure 逻辑应用和 Azure Service Fabric。An API can be composed of APIs exposed by different services, including the OpenAPI Specification, a SOAP API, the API Apps feature of Azure App Service, Azure Function App, Azure Logic Apps, and Azure Service Fabric.

导入 API

若要将其他 API 追加到现有 API,请完成以下步骤。To append a different API to your existing API, complete the following steps. 导入另一个 API 时,操作将追加到当前 API 后面。When you import another API, the operations are appended to your current API.

  1. 在 Azure 门户中转到自己的 Azure API 管理实例。Go to your Azure API Management instance in the Azure portal.
  2. 在左侧菜单中选择“API”。Select APIs from the menu on the left.
  3. 单击要将另一个 API 追加到的 API 旁边的“...”。Click ... next to the API that you want to append another API to.
  4. 从下拉菜单中选择“导入”。Select Import from the drop-down menu.
  5. 选择要从中导入 API 的服务。Select a service from which to import an API.

后续步骤Next steps