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.
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.
-
Launch VS Code with the WSO2 Integrator: BI extension installed.
-
Click the WSO2 Integrator: BI icon on the Activity Bar of VS Code.
-
Click Create New Integration.
Next, the Create Your Integration dialog will open.
-
In the Create Your Integration, enter
ServiceCatalogSampleas the Integration Name. -
Provide a location under Select Path.
-
Click Create Integration.
Now let's start designing the integration by adding the necessary artifacts.
Create an HTTP service
-
Navigate to WSO2 Integrator: BI Project Design.
-
Click on the + Add Artifact Button.
-
Click HTTP Service under Integration as API.
-
Enter
healthcarein the Service Base Path, then click Create. -
Click on the + Add Resource Button.
-
Select the GET method, enter the Resource Path as
querydoctor, add the Query Parametercategory, and click Save. -
Click on the + Button.
-
Click on the Return Button.
-
Provide the example return value as shown below, then click Save.
[ { "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¶
-
Click on the
</>Button. -
Add
import ballerinax/wso2.apim.catalog as _;after the existing imports, then click the File View icon in the top-left corner. -
Select
Ballerina.tomlfile and addremoteManagement = trueafter the existing[build-options]. -
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.[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
clientIdandclientSecretshould 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>" -
Start the API Manager runtime before starting the WSO2 Integrator: BI.
- Download and set up WSO2 API Manager.
- Start the API-M server.
Step 4: Run the application¶
-
Select the BI Extension icon and click the Run button to execute.
-
After signing in to the API Publisher portal:
https://localhost:9443/publisher, you can see the created service. -
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.