機械翻訳について

Webフック・トリガーとは

webフック・トリガーを使用すると、外部アプリケーションは、アプリケーション内で特定のイベントが発生するたびに、Webフックを使用して新しいデータを自動的にOracle Integrationに送信します。 新しいデータを受信すると、統合フローが実行され、データが処理されます。

webフック・トリガーは、次の2つの契約で構成されます。 Rapid Adapter Builderは、これらの契約の設計と、一方のフォームからもう一方のフォームへのマッピングをサポートします。

Webフック契約

webフック・コントラクトは、ヘッダー、問合せパラメータおよび本文コンポーネントを含む外部アプリケーション(HTTPポストを介して送信される可能性が高い)によって送信されるRAWインバウンド・メッセージです。

webフックを処理するには:

  • typeプロパティをwebhookに設定します。

  • httpMethodプロパティをPOSTまたは要件に従って設定します。

  • webhookプロパティで、ヘッダー、問合せパラメータおよびwebフック・リクエストの本文をモデル化します。

  • requestプロパティで、統合マッパーに表示されるメッセージの構造をモデル化するJSONスキーマを参照します。

webフックでは、ヘッダーまたは問合せパラメータをモデル化する必要がない場合があります。 また、ほとんどの場合、webフック本文全体を統合開発者に提示でき、生のインバウンドWebフック・リクエストを別の形式に変換する必要はありません。 したがって、通常、リクエスト・スキーマと本文スキーマは、次の例に示すように同じにできます。

"OrderProcessedTrigger": {
    "displayName": "Order Processed Event",
    "description": "This event gets triggered when order has been processed.",
    "group": "Orders",
    "type": "webhook",
    "httpMethod": "POST",
    "webhook": {
        "header" : {
            "type": "object",
            "properties": {
                "name" : "x-custom-header",
                "type": "string"
            }
        },
        "body": {
            "schemaType": "application/schema+json",
            "schema": {
                "$ref": "#/schemas/OrderEventSchema"
            }
        }
    }
    "request" : {
        "schemaType": "application/schema+json",
        "schema": {
            "$ref": "#/schemas/OrderEventSchema"
        }
    }
}

マッパー契約

マッパー・コントラクトは、Oracle Integrationマッパーに表示されるトリガー・リクエスト(requestプロパティでモデル化)です。

RAWのインバウンドwebフック・リクエストを別の形式に変換する場合は、executeプロパティを使用してWebフックを処理し、RAWリクエストを目的のスキーマ(requestプロパティで指定)に変換できます。

また、webフック本文とリクエスト・プロパティの両方をフローによって駆動し、スキーマを動的に導出できます。

次の例では、requestプロパティはフローを参照し、外部アプリケーションのメタデータAPIへのコールに基づいて動的スキーマを作成します。 このスキーマは、Oracle Integrationマッパーに表示されます。 executeプロパティは、webフック・メッセージをマッパーに提示された最終メッセージに変換するフローも参照します。

 "OrderProcessedTrigger": {
            "displayName": "Order Processed Event",
            "description": "This event gets triggered when order has been processed.",
            "group": "Orders",
            "type": "webhook",
            "httpMethod": "POST",
            "contentType": "application/cloudevents+json",
            "request": "flow:createRefinedrderEventSchema",
            "webhook": {
                "body": {
                    "schemaType": "application/schema+json",
                    "schema": {
                        "$ref": "#/schemas/OrderEventSchema"
                    }
                }
            }
            "execute" : "flow:processOrderWebhookMsgToRetrieveOrderObjectFlow"
        }

次に、メタデータAPIコールから外部アプリケーションへのカスタム・フィールド拡張でエンリッチされる静的スキーマに基づくrequestスキーマの作成を示すrequestフローの例を示します。

"createRefinedrderEventSchema": {
    "id": "createRefinedrderEventSchema",
    "version": "0.1",
    "start": "startState",
    "specVersion": "0.8",
    "functions": [
      {
        "name": "getStaticSchema",
        "type": "expression",
        "operation": ".self.schemas.OrderEventSchema"
      },
      {
        "name": "dynamicFlow1",
        "operation": "connectivity::rest",
        "type": "custom"
      },
      {
        "name": "dynamicFlow2",
        "operation": "connectivity::rest",
        "type": "custom"
      },
      {
        "name": "dynamicFlow3",
        "operation": "connectivity::rest",
        "type": "custom"
      },
      {
        "name": "dynamicFlow4",
        "operation": "connectivity::rest",
        "type": "custom"
      },
      {
        "name": "constructResult",
        "type": "expression",
        "operation": ".staticOutput"
      },
      {
        "name": "constructReturnObject",
        "type": "expression",
        "operation": "{\"schemaType\": \"application/schema+json\", \"schema\": .schema}"
      }
    ],
    "states": [
      {
        "name": "startState",
        "type": "operation",
        "actions": [
          {
            "functionRef": "getStaticSchema",
            "actionDataFilter": {
              "toStateData": "${ .staticOutput }"
            }
          },
          {
            "functionRef": {
                "refName": "dynamicFlow1",
                "arguments": {
                    "uri": "${\"https:/\"+\"/\"+.connectionProperties.invokeHostName+\"/settings/custom-fields/zuora/Order\"}",
                    "method": "GET"
                }
            },
            "actionDataFilter": {
                "results": "${ .body | .schema.properties | with_entries(select(.value.type != null)) | map_values({type: .type})}",
                "toStateData": "${ .staticOutput.properties }"
            }
          },
          {
            "functionRef": {
                "refName": "dynamicFlow2",
                "arguments": {
                    "uri": "${\"https:/\"+\"/\"+.connectionProperties.invokeHostName+\"/settings/custom-fields/zuora/Account\"}",
                    "method": "GET"
                }
            },
            "actionDataFilter": {
                "results": "${ .body | .schema.properties | with_entries(select(.value.type != null)) | map_values({type: .type})}",
                "toStateData": "${ .staticOutput.properties }"
            }
          },
          {
            "functionRef": {
                "refName": "dynamicFlow3",
                "arguments": {
                    "uri": "${\"https:/\"+\"/\"+.connectionProperties.invokeHostName+\"/settings/custom-fields/zuora/PaymentMethod\"}",
                    "method": "GET"
                }
            },
            "actionDataFilter": {
                "results": "${ .body | .schema.properties | with_entries(select(.value.type != null)) | map_values({type: .type})}",
                "toStateData": "${ .staticOutput.properties }"
            }
          },
          {
            "functionRef": {
                "refName": "dynamicFlow4",
                "arguments": {
                    "uri": "${\"https:/\"+\"/\"+.connectionProperties.invokeHostName+\"/settings/custom-fields/zuora/Contact\"}",
                    "method": "GET"
                }
            },
            "actionDataFilter": {
                "results": "${ .body | .schema.properties | with_entries(select(.value.type != null)) | map_values({type: .type})}",
                "toStateData": "${ .staticOutput.properties }"
            }
            },
          {
            "functionRef": "constructResult",
            "actionDataFilter": {
              "toStateData": "${ .schema }"
            }
          },
          {
            "functionRef": "constructReturnObject",
            "actionDataFilter": {
              "toStateData": "${ .output }"
            }
          }
        ],
        "end": true
      }
    ]
}