Skip to content

Expose an Integration Service as a Managed API

What you'll build

In this tutorial, you'll define an integration service using WSO2 Integrator: BI and expose it as a managed API to the API marketplace. API consumers then discover the API from the marketplace, subscribe to it, and use it for application development.

exposing integration service as a managed api

This demonstrates how the integration components and API management components of WSO2 API Manager work together to enable API-led integration.

Let's get started!

Follow the steps given below to build this use case and try it out.

Step 1: Set up the workspace

You need Visual Studio Code (VS Code) with the WSO2 Integrator: BI extension installed.

Info

See the Install WSO2 Integrator: BI to learn how to install WSO2 Integrator: BI for VS Code.

Step 2: Develop the integration artifacts

Follow the instructions given in this section to create and configure the required artifacts.

Create an integration project

The Integration project will contain all the required artifacts for the integration solution.

  1. Launch VS Code with the WSO2 Integrator: BI extension installed.

  2. Click the WSO2 Integrator: BI icon on the Activity Bar of VS Code.

  3. Click Create New Integration.

    Next, the Create Your Integration dialog will open.

  4. In the Create Your Integration, enter ServiceCatalogSample as the Integration Name.

  5. Provide a location under Select Path.

  6. Click Create Integration.

    create an integration project

Now let's start designing the integration by adding the necessary artifacts.

Create an HTTP service

  1. Navigate to WSO2 Integrator: BI Project Design.

  2. Click on the + Add Artifact Button.

  3. Click HTTP Service under Integration as API.

  4. Enter healthcare in the Service Base Path, then click Create.

    create an http service

  5. Click on the + Add Resource Button.

    add resource

  6. Select the GET method, enter the Resource Path as querydoctor, add the Query Parameter category, and click Save.

    resource

  7. Click on the + Button.

  8. Click on the Return Button.

    return button

  9. Provide the example return value as shown below, then click Save.

    return value

    [
        {
            "name":"thomas collins",
            "hospital":"grand oak community hospital",
            "category":"surgery",
            "availability":"9.00 a.m - 11.00 a.m",
            "fee":7000.0
        },
        {
            "name":"anne clement",
            "hospital":"clemency medical center",
            "category":"surgery",
            "availability":"8.00 a.m - 10.00 a.m",
            "fee":12000.0
        },
        {
            "name":"seth mears",
            "hospital":"pine valley community hospital",
            "category":"surgery",
            "availability":"3.00 p.m - 5.00 p.m",
            "fee":8000.0
        }
    ]
    

Step 3: Create configuration for APIM

  1. Click on the </> Button.

    code button

  2. Add import ballerinax/wso2.apim.catalog as _; after the existing imports, then click the File View icon in the top-left corner.

    import button

  3. Select Ballerina.toml file and add remoteManagement = true after the existing [build-options].

    build options

  4. Use the BI Configurations and select View Configurations under Imported Libraries to add the following configurations for ballerinax/wso2.apim.catalog. Save each configuration after adding it.

    configurations

    [ballerinax.wso2.apim.catalog]
    serviceUrl = "<Url of the service catalog endpoint>"
    tokenUrl = "<Url of the token endpoint>"
    username = "<username>"
    password = "<password>"
    clientId = "<clientId>"
    clientSecret = "<clientSecret>"
    

    Info

    See the Create a Rest API documentation to learn how to get configurations.

    These are some default values, but clientId and clientSecret should be replaced with your own.

    [ballerinax.wso2.apim.catalog]
    serviceUrl = "https://127.0.0.1:9443/api/am/service-catalog/v1"
    tokenUrl = "https://localhost:9443/oauth2/token"
    username = "admin"
    password = "admin"
    clientId = "<clientId>"
    clientSecret = "<clientSecret>"
    
  5. Start the API Manager runtime before starting the WSO2 Integrator: BI.

    1. Download and set up WSO2 API Manager.
    2. Start the API-M server.

Step 4: Run the application

  1. Select the BI Extension icon and click the Run button to execute.

    run-icon

  2. After signing in to the API Publisher portal: https://localhost:9443/publisher, you can see the created service.

    service-in-APIM

  3. After connecting to APIM, your integration service will appear as a managed API in the API Publisher portal. From there, you can configure and deploy the API, publish it to the Developer Portal, test it using the integrated API console, and allow consumers to subscribe and invoke the API securely.

Tip

For detailed instructions, see Invoke an API using the Integrated API Console.