This documentation is for WSO2 Governance Registry 5.1.0. View documentation for the latest release.
||
Skip to end of metadata
Go to start of metadata

This guide demonstrates how to integrate an external WSO2 API Manager (APIM) with WSO2 G-Reg. For information on installing WSO2 API Manager features internally within WSO2 G-Reg, see  Installing WSO2 API Manager Features.

Introduction

WSO2 Governance Registry is a registry-repository for storing and managing metadata related to services and other artifacts. Services  ( 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, in WSO2 APIM service publication is done using the APIM Publisher 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 guide explains how to configure the two products to expose services in the G-Reg as APIs in the APIM.

Prerequisites

Follow the steps below to set up the required prerequisites before starting the integration.

  1. Download WSO2 API Manager (1.9.x versions), and start the server. For instructions on running WSO2 APIM, see  Running the Product.
  2. Download WSO2 Governance Registry (version 5.0.0 and above) 
  3. Change the default port of WSO2 G-Reg (e.g. set a port offset of 1)to avoid port conflicts that may arise when running more than one WSO2 products on the same server. For instructions, see Changing the Default Ports with Offset.
  4. Start the WSO2 G-Reg server.  For instructions on running WSO2 G-Reg, see Running the Product. 

Configuring WSO2 G-Reg to publish services

Follow the steps below to configure WSO2 G-Reg to publish services on it to WSO2 APIM.

  1.  Log in to the G-Reg Management Console using the following URL and admin/admin credentials:  https://10.100.5.72:9444/carbon

  2. Click Extensions, and then click Lifecycles.
  3. Click the corresponding View/Edit Link of the ServiceLifeCycle as shown below.
    edit the ServiceLifeCycle configuration
  4. Replace the  <execution forEvent="Publish" class="org.wso2.carbon.governance.registry.extensions.executors.apistore.ApiStoreExecutor"> element in the configuration with a code block which defines an execution element in production 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.

    Alternatively, you can do this change in the <GREG_HOME>/repository/resources/lifecycles/ServiceLifeCycle.xml file and then restart the G-Reg server.

    <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>

    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 an  execution  element in  production  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.

    <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>
  5. Click Save.

  6. Click Yes in the message which pops up.

Configuring to publish multiple (SOAP and REST) service types

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.

  1. Log in to the G-Reg Management Console using the following URL and admin/admin credentials:  https://10.100.5.72:9444/carbon
  2. Click Extensions, and then click Lifecycles.
  3. Click the corresponding View/Edit Link of the ServiceLifeCycle.
  4. Copy the configuration in the editor, and click Cancel.
  5. Click Add New Lifecycle.
  6. Paste the configuration which you copied in the editor.
  7. Replace the configuration of the executor accordingly as per step 4 in the Configuring WSO2 G-Reg section above.
  8. Change the name of the lifecycle as shown in the example below.
    <aspect name="NewServiceLifeCycle" class="org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle">
  9. Click Save, and then click Artifact Types in the left navigation menu.
  10. Click the View/Edit link of the Artifact Type to which you need to assign the new lifecycle with the corresponding executor (i.e. soapservice or restservice)
  11. Enter the name of the new lifecycle in the configuration as shown in the example below.
    <lifecycle>NewServiceLifeCycle</lifecycle>
  12. Click Save.

Creating the Service in WSO2 G-Reg

Follow the steps below to create the service in WSO2 G-Reg which you need to publish to WSO2 APIM.

  1. Create a new SOAP service in WSO2 G-Reg. For instructions, see Adding a SOAP Service.

    For instructions on creating a REST service to publish it to WSO2 API Manager, see Adding a REST Service.

  2. Log in to the G-Reg Management Console using the following URL and admin/admin credentials:  https://10.100.5.72:9444/carbon
  3. Click Main, and then click SOAP Services in the List menu.

    You view the created SOAP service. 

  4. Click on the corresponding Service Version link of the service as shown below.
    click Service Version of the new service

  5. Add the same values which you provided for the apim.endpoint parameter (e.g. http://localhost:9763/), and apim.env parameter (e.g. "dev") in the lifecycle executer in Configuring WSO2 G-Regfor Environments and URL as shown in the example below.   
    endpoint URL
  6. Click Save SOAP Service.

Publishing the Service in WSO2 G-Reg

Publish the service you created to the APIM Publisher. For instructions, see Managing Life Cycles of Assets.

Testing the API Published in WSO2 APIM 

Follow the steps below to test the API published in the WSO2 APIM by invoking it.

  1. 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.
    API published in WSO2 APIM
  2. Click on the API.
  3. Click Edit as shown below.
    editing the API
  4. Click Next: Implement > in the following screen.
    designing the API
  5. Click Managed API as shown below.
    Managed API
  6. Enter the preferred Production Endpoint, and click Next : Manage > as shown below.
    implementing the API
  7. Enter preferred details, and click Save & Publish as shown below.
    managing the API
  8. Click Go to API Store in the message which pops up as shown below.
    Click Go to API Store button
  9. Select an Application, and click Subscribe as shown below.
    subscribe to API
  10. Click Go To My Subscriptions in the message which pops up as shown below.
    click Go to My Subscriptions
  11. Click Generate keys button in the Keys - Production section as shown below. 

    You can skip this step if you already did it before.

    generate keys
    You view the generated keys as shown below.
    generated keys

  12. Click on the API which you subscribed in the Subscribed APIs section at the end of the screen as shown below.
    subscribed APIs
  13. Click on the API Console tab, and click on the POST box, to expand it as shown below.
    click POST in the API Console
  14. Click the Try it out! button. You view the result of invoking the API as shown in the below example.
    result of invoking the API
  • No labels