Create and Manage Tenants using Admin Services in WSO2 Products

Vithursa Mahendrarajah
2 min readJun 17, 2019

--

Multi-tenancy architecture is supported in WSO2 products which enables the feature to share a single instance of deployment among multiple separate business entities. We can consider each business entity as a tenant. Here, I am going to guide you through the steps to manage tenants using Admin Services instated of using UI.

There are two admin services available for managing tenant operations:

  • TenantMgtAdminService,
  • RemoteTenantManagerService

Follow the steps given below to invoke the SOAP Admin service to create tenant. I am going to use TenantMgtAdminService in this blog.

  • Set following configuration as false in carbon.xml which can be found in <APIM-Home>/repository/conf directory.
<HideAdminServiceWSDLs>false</HideAdminServiceWSDLs>
  • Start the server. If you want to start the server in OSGI mode use following system property when starting up the server.
-DosgiConsole=true

WSDL of TenantMgtAdminService can be obtained in following URL (Make sure to append “?wsdl” in URL):

https://<Ip-address>:<port>/services/RemoteTenantManagerService?wsdl

Create new SOAP project in SOAP UI with the above-mentioned URL. Admin is able to perform following operations related to tenant using this admin service:

Fig 1. Supported operations

Create a request for addTenant, by specifying relevant parameters. Sample request can be found below:

<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope" xmlns:ser=”http://services.mgt.tenant.carbon.wso2.org" xmlns:xsd=”http://beans.common.stratos.carbon.wso2.org/xsd">
<soap:Header/>
<soap:Body>
<ser:addTenant>
<ser:tenantInfoBean>
<xsd:active>true</xsd:active>
<xsd:admin>tenantAdmin</xsd:admin>
<xsd:adminPassword>xxxx</xsd:adminPassword>
<xsd:email>test@gmail.com</xsd:email>
<xsd:firstname>testUser</xsd:firstname>
<xsd:lastname>testUser</xsd:lastname>
<xsd:tenantDomain>test.com</xsd:tenantDomain>
<xsd:tenantId>1</xsd:tenantId>
</ser:tenantInfoBean>
</ser:addTenant>
</soap:Body>
</soap:Envelope>

You can retrieve the tenant using getTenant operation and verify the tenant creation operation. GetTenant method requires tenant domain as input parameter.

Please note that when invoking admin services, we need to send Basic Auth headers with super admin username and password. ^_^

--

--

Vithursa Mahendrarajah
Vithursa Mahendrarajah

Written by Vithursa Mahendrarajah

Software Engineer at WSO2, Electronic &Telecommunication Engineering Graduate, University of Moratuwa. Also like to be a content crafter ^_^

No responses yet