Nav

To Configure the Auto-Discovery XML Element (Mule 3)

Before you configure auto-discovery, you publish the API in Exchange and, then in API Manager, configure management of the API.

You use one of the following procedures to set up auto-discovery of an API deployed in Mule Runtime 3.x:

  • Method 1: Set up the global auto-discovery element on XML Editor.

    Include the name and version-based auto-discovery element in the configuration.xml.

    Or

  • Method 2: Set up the global auto-discovery element in Studio 6.

Method 1: Set up the global auto-discovery element on XML Editor.

In Mule 3.x, the API name and version reference to the API’s main flow identify the API. The main flow is where the HTTP listener is defined.

  1. In API Administration, click the API version name.

    click version

    The version details page, which shows the API name and version, appears.

    name version
  2. Use the following syntax to specify the apiName and version in the configuration.xml:

    <api-platform-gw:api apiName="${apiName}" version="${apiVersion}" flowRef="proxy" />

    The API name consists of a UUID, which is the group ID and the Exchange asset ID. The API version consists of the version name and the instance ID or the label.

Method 2: Studio 6 Configuration

First, you get the Client-ID and Secret from Access Management in Anypoint Platform. You need these credentials for configuration of auto-discovery in Studio. In Studio, you pair Anypoint Studio with an Anypoint Platform environment in your organization by adding the credentials to Studio Preferences. You configure auto-discovery for each flow you want to manage using a global element.

  1. In a browser, log in to Anypoint Platform as an administrator, click Access Management > Environments. Click an environment.

    The environment client ID and client secret appear. You copy/paste these credentials later.

    env clientid clientsecret

    Alternatively, you can get the organization client ID and client secret to copy/paste later:

    • Click Access Management > Organization.

    • In Name, click the organization name from the list.

      The Organization Info appears:

      org id
  2. In Studio, from the main menu, select Anypoint Studio > Preferences > Anypoint Studio > Anypoint Platform for APIs.

    The Preferences dialog for Anypoint Platform for APIs appears.

  3. Copy the environment or organization client ID and client secret from step 1 and paste to Client Credentials.

    autodis-pairing

    This action pairs Mule Runtime with your Anypoint Platform organization’s environment.

  4. Click Validate to verify that the pairing succeeds.

  5. In Project Explorer, select the app. For example, select api.xml in src/main/app that you created in the APIkit tutorial.

  6. On the Global Elements tab on the canvas, click Create.

    autodis cerate global2

    The Choose Global Type dialog appears.

  7. Select Component Configurations > API Autodiscovery.

    autodis choose global2

    The Global Element Properties - API Autodiscovery dialog appears.

  8. Create a global element to declare the details of the API version you want Anypoint Platform to discover:

    • The API name consists of a UUID, which is the group ID and the Exchange asset ID. The version details page shows the API name and version as descibed in method 1.

    • The API version consists of the version name and the instance ID or the label. The version details page shows the API name and version as descibed in method 1.

    • In Flow Name, select the name of the flow in the API to which you want to direct requests. For example, select api-main, the APIkit tutorial main flow.

    • In APIkit Router Configuration, click api-config from the drop-down in the case of the APIkit tutorial.

      This configuration is not used by API Manager.

    • In Description, write some documentation about the API.

      auto-disc-conf2

  9. In Project Explorer, right-click the app, api.xml in this example, and select Run As > Mule Application.

The API is now manageable from API Manager.