Updated on 2025-09-04 GMT+08:00

Interconnecting with ROMA Connect to Call Service APIs

ROMA Connect is a full-stack application & data integration platform. It integrates data, APIs, messages, and devices to allow interconnection between cloud and on-premises applications, helping enterprises achieve digital transformation. After Huawei Cloud Astro Zero is connected to ROMA Connect using a connector, Huawei Cloud Astro Zero can call ROMA Connect APIs to integrate services.

Prerequisites

Huawei Cloud Astro Zero provides a ROMA Connect server that is interconnected by default and can also interconnect with your own ROMA Connect instances. This section describes how to interconnect Huawei Cloud Astro Zero with your own ROMA Connect. The configuration of the ROMA Connect server interconnected by default is similar.

  • You have created an application on ROMA Connect. (When creating an application, ensure that the Key of the application contains fewer than 60 characters. Otherwise, the application will fail to be synchronized to Huawei Cloud Astro Zero.) You have created a function API, an API group, and an API, and have debugged, published, and authorized the application. For details about operations on ROMA Connect, see Using ROMA Connect for Message Integration and Authorizing Applications to Call an API.
  • On ROMA Connect, the values of app_secret and app_route have been set to on.

    Modification method: On the instance information page of the ROMA Connect instance console, click configuration parameters and change the values of app_secret and app_route to on.

  • When interconnecting with a self-owned ROMA Connect instance, ensure that the ROMA Connect instance information has been set in Huawei Cloud Astro Zero by referring to Configuring the ROMA Connect Information.

Billing

After connecting an application to the ROMA Connect connector, you must pay for the ROMA Connect service separately. For details, see Huawei Cloud Pricing. After an application is disabled, ROMA Connect is still billed based on the preset billing rules.

Calling ROMA Connect APIs on Huawei Cloud Astro Zero

Applications created on ROMA Connect and APIs published on ROMA Connect can be directly synchronized to Huawei Cloud Astro Zero. The ROMA Connect connector of Huawei Cloud Astro Zero can be used to call ROMA Connect APIs in flows or events.

  1. Check whether the key value of the application created on ROMA Connect contains a prefix. If yes, create a system parameter in Huawei Cloud Astro Zero.

    1. Log in to the ROMA Connect console and choose Integration Applications from the navigation pane. Click the application name to access the application details and obtain the value of Key.
      • If the Key value has a prefix, for example, test__com.appcube.user, and the prefix is test__, you need to go to 1.b.
      • If the Key value does not contain a prefix, for example, com.appcube.user, go to 2.
    2. Create a system parameter.
      1. On the Huawei Cloud Astro Zero console, click Access Homepage.
      2. Click in the upper left corner of the page and choose Environments > Environment Configuration.
      3. In the navigation pane, choose System Settings > System Parameters.
      4. Click New to create the system parameter roma_app_prefix. Set the parameter value to test__. Huawei Cloud Astro Zero will add this prefix when synchronizing and calling APIs.
        Figure 1 Creating a system parameter

  2. Synchronize ROMA Connect applications and APIs in the connector and view the APIs.

    1. Log in to the application designer by referring to Logging In to the Application Designer.
    2. In the navigation pane, choose Integrations.
    3. Click Connector Instance under Connector.
    4. In the navigation pane, choose HTTP > ROMA.
    5. Click Synchronize to synchronize the applications registered on ROMA Connect to the platform.
      Figure 2 Clicking Synchronize

      After the synchronization, you can view the corresponding application in the ROMA Connect connector list.

      Applications in the ROMA Connect connector can be synchronized from ROMA Connect or imported from the installation package. The applications in the ROMA Connect connector imported using the installation package do not exist on ROMA Connect. You need to import ROMA Connect assets to the ROMA Connect platform so that you can use ROMA Connect connectors.

    6. Click the corresponding connector name. On the API tab page on the right, click the synchronize API button to synchronize the APIs released and authorized on ROMA Connect to Huawei Cloud Astro Zero.

      After the synchronization, you can view the API for obtaining personnel information on the API tab page.

    7. Click an API name to view the API details, including the basic information, message header input parameters, input parameters, and output parameters.

      If the API is updated on ROMA Connect, release and authorize the API again on ROMA Connect, and synchronize the application and API again in Huawei Cloud Astro Zero.

      Table 1 describes the API parameters.

      Table 1 API parameters

      Category

      Parameter

      Description

      Input parameters of the message header

      X-HW-APPKEY

      X-HW-APPKEY: request key of the ROMA application, which is used for private key authentication.

      1. In the navigation pane of the ROMA Connect console, choose Integration Applications.
      2. Click an application name to go to its general page.
      3. Click on the right of Secret to view the secret information.

      X-HW-ID

      Key value of the ROMA application.

      1. In the navigation pane of the ROMA Connect console, choose Integration Applications.
      2. Click an application name to go to its general page.
      3. On the displayed page, view the Key value.

      Accept

      Receiving type. The default value is application/json.

      Input Parameters

      userID

      User ID, which is a user-defined input parameter.

      Output Parameters

      retCode

      Result code.

      retJSON

      Receives data returned by ROMA Connect in JSON format.

      $out

      Receives data returned by ROMA Connect in JSON format.

      For POST requests, the input parameter contains $body, which is used to transfer the body structure. You can use the output parameter $out to receive unformatted data returned by ROMA Connect after the copyright information is set. $out indicates the structure type.

      If the service needs to add other message header input parameters or input parameters to an API, edit the API on the API management page of ROMA Connect, define the input parameters, release and authorize the API again, and synchronize the API on Huawei Cloud Astro Zero again.

Calling ROMA Connect APIs in a Flow

  1. Create a flow by referring to Creating a Blank Flow.
  2. On the left of the flow design page, choose Connector > ROMA and drag the personnel management diagram element (connector name is the ROMA application name) to the canvas.
  3. Set variables and input and output parameters of the flow by referring to Table 1.

    1. Select the Start diagram element and select on the right of the flow design page.
    2. On the private structure page, click the add button.
      Before creating the output parameter structure variable, you need to create a private structure.
      Figure 3 Adding a private struct
    3. Add an empty private struct retJson. You do not need to set the structure members.
      Figure 4 Creating a private struct
    4. On the right of the flow designer, click .
    5. On the Context panel, click the plus sign (+) next to Object Variable.
      Figure 5 Adding an object variable
    6. Select Private, set the page parameters, set the name to retJson, and select the created private structure retJson.
      Figure 6 Setting a private structure variable

    7. Repeat the preceding operations to add the out private structure variable and select the created out private structure.
      Figure 7 out variable
    8. On the right of the flow designer, click .
    9. On the Context page, click the plus sign (+) next to Variable to add two variables in Figure 9.
      Figure 8 Creating variables
      Figure 9 Adding two variables
    10. Click the Start diagram element or the blank area in the canvas. On the right of the flow design page, select and set the input and output parameters of the flow.
      Figure 10 Setting the input and output parameters of the flow
    11. Create the system parameter appkey by referring to Setting System Parameters and set the value to the request key of the ROMA application.

      X-HW-APPKEY is the request key of the ROMA application and may change. You can create a system parameter, encrypt the input parameter, and reference it using a formula. When the request key changes, modify the system parameter.

      Figure 11 Creating the system parameter appkey
    12. On the right of the flow designer, click .
    13. On the Context page, click the plus sign (+) next to Formula to create a formula variable appkey. The expression is SYSPARAMETER("appkey").
      Figure 12 Creating a formula variable

  4. On the connector page, set the action to the API to be called, for example, "Obtain Personnel Information", set the input and output parameters based on Table 1, and connect the diagram elements.

    • Action: API to be called. The API options are synchronized from 2.f.
    • Input parameters: input parameters for calling the API.
    • Output parameters: input parameters for calling the API.

  5. Click in the upper part of the flow page to save the flow.
  6. Click in the upper part of the editor page to execute the flow.
  7. Set input parameters and click the run button.

    An example of parameter settings is as follows:

    {
        "userid": "001"
    }

    If the following information is displayed, the ROMA Connect API is successfully called:

    {
      "interviewId": "002N000000cOeh5XCDrc",
      "outputs": {
        "out": {
          "retCode": "0",
          "retJSON": {
            "result": {
              "employ_name": "zhangsan",
              "employ_no": "00xxxxxx"
            }
          }
        },
        "retCode": "0",
        "retJson": {
          "result": {
            "employ_name": "zhangsan",
            "employ_no": "00xxxxxx"
          }
        }
      }
    }

Calling the ROMA Connect API in a Script

  1. Create an empty script by referring to Creating a Blank Script.
  2. In the script editor, enter the following code:

    // Here's your code.
    import * as roma from "roma";
    import * as sys from "sys";
    // Create a client using the ROMA application name. The second parameter is optional. For example, roma.newClient ("Personnel Management").
    let client1 = roma.newClient (" Personnel Management ," roma.NameType.AppName)
    
    // Create a client using the app ID of the ROMA app.
    let client2 = roma.newClient("com.appcube.user", roma.NameType.AppId)
    
    //Call the API by API name. The first parameter is the API name, and the input parameter is transferred in the second parameter. The body parameter can be transferred in $body.
    let resp1 = client1.sendRest("Obtain personnel information", {
        "X-HW-APPKEY": sys.getParameter("appkey"),
        "X-HW-ID": "com.appcube.user",
        userID: "1110000",
        $body: {}
    });
    console.log(resp1.$out)
    
    //Call the API through the URL. The first parameter is the request method, and the second parameter is the API URL. The input parameter is transferred in the third parameter. The body parameter can be transferred in $body.
    let resp2 = client1.sendRestByURL("GET", "/getUserInfo", {
        "X-HW-APPKEY": sys.getParameter("appkey"),
        "X-HW-ID": "com.appcube.user",
        userID: "1110000",
        $body: {}
    });
    console.log(resp2.$out)

  3. Click in the upper part of the script editor to save the script.
  4. Click in the upper part of the editor page to execute the script.
  5. Input parameters have been set in the script. Click in the upper right corner of the test window to execute the script.

    If the following information is displayed on the log tab page, the ROMA Connect API is successfully called:
    0813 16:33:31.504|debug|vm[2]>>> app cube 1.2.12 8fce52d0 2020-07-17 10:14:41 +0800 debug
    0813 16:33:31.504|debug|vm[2]>>> node: 1
    0813 16:33:31.504|debug|vm[2]>>> script: test10__roma 1.0.1 
    0813 16:33:31.504|debug|vm[2]>>> locale: zh_CN
    0813 16:33:31.504|debug|vm[2]>>> timezone: Local
    0813 16:33:31.723|debug|vm[2]>>> { retCode: '0', retJSON: { result: { employ_name: 'zhangsan', employ_no: '00xxxxxx' } } } (test10__roma.ts:17)
    0813 16:33:31.773|debug|vm[2]>>> { retCode: '0', retJSON: { result: { employ_name: 'zhangsan', employ_no: '00xxxxxx' } } } (test10__roma.ts:26)