...
- Copy the WSO2 API Manager product pack to two different locations.
If needed, you can download the WSO2 API Manager product pack from here.
Go to theAnchor step2 step2 <API-M_HOME>/repository/conf/carbon.xml
file of the second instance and change its port by an offset of 1.
The port offset is set to avoid the port conflicts that occur when you run more than one WSO2 product on the same host.Code Block language xml <Offset>1</Offset>
- Start both API-M servers.
Let's publish from the first instance of WSO2 API Manager to the Store of the second instance, which in this tutorial we consider as the external API Store. Sign in to the WSO2 API-M management console of the first instance (
https://<Server Host>:9443/carbon
) as admin.Tip In a multi-tenant environment, you must sign in using the tenant's credentials.
Click Main> Resources > Browse.
The Registry opens.Go to the
/_system/governance/apimgt/externalstores/external-api-stores.xml
resource.
Click the Edit as Text link, uncomment the
<StoreURL>
element under the<ExternalAPIStores>
element, and add the details of each external API store that you need to publish APIs to.
In this example,http://localhost:9764/store
is the API Store of the second WSO2 API Manager instance.- You publish to its super tenant's Store (admin/admin).
- For this tutorial change the
DisplayName
toStore2
, so that it is clear that we are referring to the second WSO2 API-M instance, which we are using as the external Store. - The port is 9764 as you incremented it by 1 in step 2.
- If the second WSO2 API Manager instance has multiple tenants and you want to publish to a tenant's Store, the tenant's Store URL and credentials must be given here.
Code Block <ExternalAPIStores> <StoreURL>http://localhost:9763/store</StoreURL> <ExternalAPIStore id="Store2" type="wso2" className="org.wso2.carbon.apimgt.impl.publishers.WSO2APIPublisher"> <DisplayName>Store2</DisplayName> <Endpoint>http://localhost:9764/store</Endpoint> <Username>admin</Username> <Password>admin</Password> </ExternalAPIStore> </ExternalAPIStores>
Tip If you want to cofigure more than one external store, change the configuration in <ExternalAPIStore> and add it to the external-api-stores.xml.
For example if we have three API Stores one is super tenant and other two are tenant stores, we can configure these three external stores as below.
Code Block <ExternalAPIStores> <!--Configuration to set the store URL of the current running APIM deployment. APIs published to external stores will be redirected to this URL--> <StoreURL>http://<ip_address>:<port>/store</StoreURL> <ExternalAPIStore id="SLStore" type="wso2" className="org.wso2.carbon.apimgt.impl.publishers.WSO2APIPublisher"> <DisplayName>SL-Store</DisplayName> <Endpoint>http://<ip_address>:<port>/store</Endpoint> <Username>admin</Username> <Password>admin</Password> </ExternalAPIStore> <ExternalAPIStore id="USStore" type="wso2" className="org.wso2.carbon.apimgt.impl.publishers.WSO2APIPublisher"> <DisplayName>US-Store</DisplayName> <Endpoint>http://<ip_address>:<port>/store</Endpoint> <Username>{tenantadmin_username}@{tenant_domain}</Username> <Password>{tenantadmin_password}</Password> </ExternalAPIStore> <ExternalAPIStore id="UKStore" type="wso2" className="org.wso2.carbon.apimgt.impl.publishers.WSO2APIPublisher"> <DisplayName>UKStore</DisplayName> <Endpoint>http://<ip_address>:<port>/store</Endpoint> <Username>{tenantadmin_username}@{tenant_domain}</Username> <Password>{tenantadmin_password}</Password> </ExternalAPIStore> </ExternalAPIStores>
Tip In a multi-tenant environment, each tenant can publish to different external Stores by changing the above file in their tenant space. For more information on how APIs appear and are available for subscription in a multi-tenant environment, see API visibility and subscription. Note that publishing to an external Store only means that the API is advertised there. To subscribe, you must always register and sign in to the original publisher's tenant Store.
Note the following in the configuration above:
Element Description <ExternalAPIStore id="" type="" className="">
id
: The external store identifier, which is a unique value.type
: The type of the Store. This can be a WSO2-specific API Store or an external one, which has a different implementation from the default WSO2 API Store.className
: The implementation class inside the WSO2 API Manager distribution.Info The default className specified is org.wso2.carbon.apimgt.impl.publishers.WSO2APIPublisher, which is used when WSO2 specific API Store is used. However, if you are using an external API Store, the class should be customized by extending the interface org.wso2.carbon.apimgt.api.model.APIPublisher, and the fully qualified class name of the new implementation should be used for the className parameter.
<StoreURL>
The URL of the API Store of the current API-M deployment. This is the URL to the API in the original publisher's store. APIs that are published to external stores are redirected to this URL. <DisplayName>
The name of the external API Store that is displayed in the Publisher UI. <Endpoint>
The URL of the external API Store. <Username>
and<Password>
The credentials of a user who has permissions to create and publish APIs.
Info The registry changes are applied dynamically. You do not need to restart the server.
Click Save Content.
Sign in to the API Publisher of the first instance as admin/admin and if you do not have any APIs that are in the published state created, create an API.
Tip In a multi-tenant environment, sign in to the API Publisher using your tenant's credentials.
Click on the newly created or existing API.
Here you see a new tab named External API Stores added to the API Publisher console.Info This tab is only visible when viewing API's that are in the published state.
Note - You can select multiple external API stores and click Save to publish your API to them.
- If the API creator updates the API after publication to external stores, either the creator or a publisher can simply push those changes to the published stores by selecting the stores, and clicking Save again.
- If the API creator deletes the API, each external store that it is published to receives a request to delete the API.
Select the Store that you want to publish to (in this case, Store2) and click Save.
Sign in to the external API Store (in this case,
http://localhost:9764/store
) and click on the API that you just published.A link appears as Visit Publisher Store, which directs you to the original publisher’s store (in this case,
http://localhost:9763/store
) through which you can subscribe to the API.
...