在带有 Enterprise Integration Pack 的 Azure 逻辑应用中交换 AS2 消息以实现 B2B 企业集成Exchange AS2 messages for B2B enterprise integration in Azure Logic Apps with Enterprise Integration Pack

重要

原始 AS2 连接器正被弃用,因此务必改用 AS2 (v2) 连接器。The original AS2 connector is being deprecated, so make sure that you use the AS2 (v2) connector instead. 此版本提供与原始版本相同的功能,是逻辑应用运行时的本机版本,在吞吐量和消息大小方面提供显著的性能改进。This version provides the same capabilities as the original version, is native to the Logic Apps runtime, and provides significant performance improvements in terms of throughput and message size. 另外,本机 v2 连接器不要求与集成帐户建立连接,Also, the native v2 connector doesn't require that you create a connection to your integration account. 但要求执行先决条件中所述的操作,确保将集成帐户关联到你计划在其中使用连接器的逻辑应用。Instead, as described in the prerequisites, make sure that you link your integration account to the logic app where you plan to use the connector.

若要在 Azure 逻辑应用中使用 AS2 消息,可以使用 AS2 连接器,它提供用于管理 AS2 通信的触发器和操作。To work with AS2 messages in Azure Logic Apps, you can use the AS2 connector, which provides triggers and actions for managing AS2 communication. 例如,若要在传输消息时确保安全性和可靠性,可以使用以下操作:For example, to establish security and reliability when transmitting messages, you can use these actions:

  • AS2 编码操作:可以通过消息处置通知 (MDN) 提供加密、数字签名和确认功能,这有助于为不可否认性提供支持。AS2 Encode action for providing encryption, digital signing, and acknowledgments through Message Disposition Notifications (MDN), which help support non-repudiation. 例如,此操作会应用 AS2/HTTP 标头并执行以下任务(在配置好以后):For example, this action applies AS2/HTTP headers and performs these tasks when configured:

    • 对传出消息进行签名。Signs outgoing messages.
    • 加密传出消息。Encrypts outgoing messages.
    • 压缩消息。Compresses the message.
    • 在 MIME 标头中传输文件名。Transmits the file name in the MIME header.
  • AS2 解码操作:可以通过消息处置通知 (MDN) 提供解密、数字签名和确认功能。AS2 Decode action for providing decryption, digital signing, and acknowledgments through Message Disposition Notifications (MDN). 例如,该操作执行以下任务:For example, this action performs these tasks:

    • 处理 AS2/HTTP 标头。Processes AS2/HTTP headers.
    • 协调收到的 MDN 和原始的出站消息。Reconciles received MDNs with the original outbound messages.
    • 更新并关联不可否认性数据库中的记录。Updates and correlates records in the non-repudiation database.
    • 写入 AS2 状态报告的记录。Writes records for AS2 status reporting.
    • 输出 base64 编码的有效负载内容。Outputs payload contents as base64-encoded.
    • 确定是否需要 MDN。Determines whether MDNs are required. 根据 AS2 协议,确定 MDN 应该是同步还是异步。Based on the AS2 agreement, determines whether MDNs should be synchronous or asynchronous.
    • 根据 AS2 协议生成同步或异步 MDN。Generates synchronous or asynchronous MDNs based on the AS2 agreement.
    • 在 MDN 上设置关联令牌和属性。Sets the correlation tokens and properties on MDNs.

    此操作还会在进行了配置的情况下执行以下任务:This action also performs these tasks when configured:

    • 验证签名。Verifies the signature.
    • 对消息进行解密。Decrypts the messages.
    • 解压缩消息。Decompresses the message.
    • 检查并禁止消息 ID 重复。Check and disallow message ID duplicates.

本文介绍如何向现有的逻辑应用添加 AS2 编码和解码操作。This article shows how to add the AS2 encoding and decoding actions to an existing logic app.

先决条件Prerequisites

  • Azure 订阅。An Azure subscription. 如果还没有 Azure 订阅,请注册一个 Azure 试用帐户If you don't have an Azure subscription yet, sign up for a trial Azure account.

  • 要从其使用 AS2 连接器的逻辑应用,以及用于启动逻辑应用工作流的触发器。The logic app from where you want to use the AS2 connector and a trigger that starts your logic app's workflow. AS2 连接器只提供操作,不提供触发器。The AS2 connector provides only actions, not triggers. 如果不熟悉逻辑应用,请查看什么是 Azure 逻辑应用快速入门:创建第一个逻辑应用If you're new to logic apps, review What is Azure Logic Apps and Quickstart: Create your first logic app.

  • 一个集成帐户,该帐户与 Azure 订阅相关联,并已关联到你计划在其中使用 AS2 连接器的逻辑应用。An integration account that's associated with your Azure subscription and linked to the logic app where you plan to use the AS2 connector. 逻辑应用和集成帐户必须位于同一位置或 Azure 区域。Both your logic app and integration account must exist in the same location or Azure region.

  • 至少两个使用 AS2 标识限定符在集成帐户中定义的贸易合作伙伴At least two trading partners that you've already defined in your integration account by using the AS2 identity qualifier.

  • 在使用 AS2 连接器之前,必须在贸易合作伙伴之间制定 AS2 协议,并将该协议存储在集成帐户中。Before you can use the AS2 connector, you must create an AS2 agreement between your trading partners and store that agreement in your integration account.

  • 如果使用 Azure Key Vault 进行证书管理,请检查保管库密钥是否允许“加密” 和“解密” 操作。If you use Azure Key Vault for certificate management, check that your vault keys permit the Encrypt and Decrypt operations. 否则,编码和解码操作会失败。Otherwise, the encoding and decoding actions fail.

    在 Azure 门户中,转到密钥保管库中的密钥,查看密钥的“允许的操作” ,确认已选择“加密” 和“解密” 操作,例如:In the Azure portal, go to the key in your key vault, review your key's Permitted operations, and confirm that the Encrypt and Decrypt operations are selected, for example:

    检查保管库密钥操作

为 AS2 消息编码Encode AS2 messages

  1. Azure 门户的逻辑应用设计器中打开逻辑应用(如果尚未打开)。If you haven't already, in the Azure portal, open your logic app in the Logic App Designer.

  2. 在设计器中,将新操作添加到逻辑应用。In the designer, add a new action to your logic app.

  3. 在“选择操作”和搜索框下,选择“全部” 。Under Choose an action and the search box, select All. 在搜索框中输入“as2 编码”,确保选择 AS2 (v2) 操作:AS2 编码In the search box, enter "as2 encode", and make sure that you select the AS2 (v2) action: AS2 Encode

    选择“AS2 编码”

  4. 现在提供以下属性的信息:Now provide information for these properties:

    属性Property 说明Description
    要编码的消息Message to encode 消息有效负载The message payload
    AS2 发件人AS2 from AS2 协议指定的消息发送方的标识符The identifier for the message sender as specified by your AS2 agreement
    AS2 收件人AS2 to AS2 协议指定的消息接收方的标识符The identifier for the message receiver as specified by your AS2 agreement

    例如:For example:

    消息编码属性

提示

如果在发送已签名或加密的消息时遇到问题,请考虑尝试不同的 SHA256 算法格式。If you experience problems when sending signed or encrypted messages, consider trying different SHA256 algorithm formats. AS2 规范不提供有关 SHA256 格式的任何信息,因此每个提供者都使用其自己的实现或格式。The AS2 specification doesn't provide any information about SHA256 formats, so each provider uses their own implementation or format.

为 AS2 消息解码Decode AS2 messages

  1. Azure 门户的逻辑应用设计器中打开逻辑应用(如果尚未打开)。If you haven't already, in the Azure portal, open your logic app in the Logic App Designer.

  2. 在设计器中,将新操作添加到逻辑应用。In the designer, add a new action to your logic app.

  3. 在“选择操作”和搜索框下,选择“全部” 。Under Choose an action and the search box, select All. 在搜索框中输入“as2 解码”,确保选择 AS2 (v2) 操作:AS2 解码In the search box, enter "as2 decode", and make sure that you select the AS2 (v2) action: AS2 Decode

    选择“AS2 解码”

  4. 对于“要编码的消息”和“消息标头”属性, ,请从以前的触发器或操作输出中选择以下值。For the Message to encode and the Message headers properties, select these values from previous trigger or action outputs.

    例如,假定逻辑应用通过“请求”触发器接收消息。For example, suppose your logic app receives messages through a Request trigger. 可以选择该触发器的输出。You can select the outputs from that trigger.

    从请求输出中选择正文和标头

示例Sample

若要尝试部署完全正常运行的逻辑应用和示例 AS2 方案,请参阅 AS2 逻辑应用模板和方案To try deploying a fully operational logic app and sample AS2 scenario, see the AS2 logic app template and scenario.

连接器参考Connector reference

有关此连接器的更多技术方面的详细信息,例如操作和限制(如此连接器的 Swagger 文件所述),请参阅连接器的参考页For more technical details about this connector, such as actions and limits as described by the connector's Swagger file, see the connector's reference page.

后续步骤Next steps