This tutorial demonstrates how to integrate an external WSO2 API Manager (APIM) 2.0.0 with WSO2 G-Reg 5.3.0.
Table of Contents | ||
---|---|---|
|
Introduction
WSO2 Governance Registry is a registry-repository for storing and managing metadata related to services and other artifacts. Services ( G-Reg implements services (i.e., SOAP or REST) in WSO2 G-Reg are implemented as configurable governance artifacts (RXT files), which you create using the G-Reg Publisher or its Management Console. Usually, you publish a service in WSO2 APIM service publication is done using the APIM Publisher Web web interface. Instead, you can integrate WSO2 APIM with WSO2 G-Reg, to directly publish APIs to APIM Publisher using the services deployed in the WSO2 Governance Registry.This G-Reg. This guide explains how to configure the two products to expose services in the G-Reg as APIs in the WSO2 APIM.
Prerequisites
Follow the steps below to set up the required prerequisites before starting the integration.
- Download WSO2 API Manager (version 1.9.x
Download WSO2 Governance Registry (version 5.0.0 and above), and start the server.
ForFor instructions on running WSO2
APIMG-Reg, see Running the Product.
Download WSO2 Governance Registry (version 5.0.0 and above).
toTip Change the default port of WSO2 G-Reg (e.g. set a port offset of 1),
whento avoid port conflicts that may arise
with Offset. Start the WSO2 G-Reg server. Forwhen running more than one WSO2 products on the same server. For instructions, see Changing the Default Ports
in the WSO2 Administration Guide.
- Download WSO2 API Manager (version 1.9.x and above), and start the server. For instructions on running WSO2 G-Reg, see APIM, see Running the Product.
Anchor | ||||
---|---|---|---|---|
|
Follow the steps below to configure WSO2 G-Reg to publish services on it to WSO2 APIM.
Log in to the G-Reg Management Console using the following URL and admin/admin credentials: https://10.100.5.72:9444/carbon
- Click Extensions, and then click Lifecycles.
- Click the corresponding View/Edit Link of the ServiceLifeCycle as shown below.
Replace theAnchor executor executor <execution forEvent="Publish" class="org.wso2.carbon.governance.registry.extensions.executors.apistore.ApiStoreExecutor">
element in the configuration with a code block which defines anexecution
element inproduction
state as shown in the example below. Add the API Manager credentials in it, so that it provides the API Manager's endpoint, username and password as executor parameters.Tip Alternatively, you can do this change in the
<GREG_HOME>/repository/resources/lifecycles/ServiceLifeCycle.xml
Code Block language html/xml <execution forEvent="Publish" class="org.wso2.carbon.governance.registry.extensions.executors.apistore.ServiceToAPIExecutor"> <parameter name="apim.endpoint" value="http://localhost:9763/"/> <parameter name="apim.username" value="admin"/> <parameter name="apim.password" value="admin"/> <parameter name="apim.env" value="dev"/> <parameter name="default.tier" value="Unlimited"/> <parameter name="throttlingTier" value="Unlimited,Unlimited,Unlimited,Unlimited,Unlimited"/> </execution>
Info If you need to publish a REST service to WSO2 API Manager, replace the
<execution forEvent="Publish" class="org.wso2.carbon.governance.registry.extensions.executors.apistore.ApiStoreExecutor">
element in the<GREG_HOME>/repository/resources/lifecycles/ServiceLifeCycle.xml
file with a code block which defines anexecution
element inproduction
state as shown in the example below. Add the API Manager credentials in it, so that it provides the API Manager's endpoint, username and password as executor parameters.Code Block language xml <execution forEvent="Publish" class="org.wso2.carbon.governance.registry.extensions.executors.apistore.RestServiceToAPIExecutor"> <parameter name="apim.endpoint" value="http://localhost:9763/"/> <parameter name="apim.username" value="admin"/> <parameter name="apim.password" value="admin"/> <parameter name="apim.env" value="dev"/> <parameter name="default.tier" value="Unlimited"/> <parameter name="throttlingTier" value="Unlimited,Unlimited,Unlimited,Unlimited,Unlimited"/> </execution>
Click Save.
Click Yes in the message which pops up.
Expand | ||
---|---|---|
|
...
If you have already published a SOAP service and if you want to publish a REST service (or vice versa) in the same G-Reg server, you need to create a new lifecycle and assign the corresponding executor to the artifact type. Follow the steps below to do this.
|
...
|
...
|
...
|
...
|
...
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
Setting up the
...
service in WSO2 G-Reg
Follow the steps below to create/edit and publish the service in WSO2 G-Reg , which you need to publish to WSO2 APIM.
- Add the same values which you provided for
Create a new SOAP service in WSO2 G-Reg. For instructions, see Creating a SOAP service.
Info For instructions on creating a REST service to publish it to WSO2 API Manager, see Creating a REST service.
- Log in to the G-Reg Management Console using the following URL and admin/admin credentials: https://10.100.5.72:9444/carbon
Click Main, and then click SOAP Services in the List menu.
You view the created SOAP service.
Click on the corresponding Service Version link of the service as shown below.
the service, which you need to publish to WSO2 APIM in WSO2 G-Reg or edit it if it is an existing one.
devTip When creating the service or editing an existing service, add the same values that you provided for the
apim.endpoint
parameter (e.g.http://localhost:9763/
), andapim.env
parameter (e.g."
inDev"
)
executer in Integrating with an External WSO2 API Manager ,when configuring the lifecycle
executor, for Environments and URL
in the Endpoints tab as shown in the example below.
- Click Save SOAP Service.
Publishing the Service in WSO2 G-Reg
...
- Publish the service you created or edited to WSO2 APIM Publisher. For instructions,
...
Info |
---|
For instructions on publishing a REST service in WSO2 G-Reg, see Publishing a REST service. |
...
Invoking the API Published in WSO2 APIM
Follow the steps below to test the API published in the WSO2 APIM by invoking it.
- Log in to the WSO2 APIM Publisher using the following URL and admin/admin credentials: https://10.100.5.72:9443/publisher. You view the service you published is successfully created as an API in the API Publisher as shown below.
- Click on the API.Click Edit , and then click Edit API as shown below.
- Click Next: Implement > in the following screen.
- Click Managed API as shown below.
- Enter the preferred Endpoint Type and Production Endpoint, and click Next : Manage > as shown below.
- Enter preferred details, and click Save & Publish as shown below.
- Click Go to API Store in the message, which pops up. You view the published API in the WSO2 APIM Store as shown below.
- Log in to WSO2 APIM Store using admin/admin credentials, and click on the published API.
- Select an Application, and click Subscribe as shown below.
- Click Go To My View Subscriptions in the message, which pops up as shown below.
Click Click Generate keys button button in the Keys - Production section the Production Keys tab as shown below.
Tip You can skip this step if you already did it before.
You view the generated keys as shown below.
- Click on the API, to which you subscribed in the Subscribed APIs section at the end of the screen Subscriptions tab as shown below.
- Click on the the API Console tab tab, and click on the the POST box box, to expand it as shown below.
- Click the the Try it out! button button. You view the result of invoking the API as shown in the below example.