Calling WSO2 Admin Services
In this blog post let’s see how to call a WSO2 Admin Service. WSO2 Admin Services are SOAP services. So you need to use one of the SOAP Clients (Like SoapUI) to call the WSO2 Admin Services. You can also call the Admin Services via CURL as well.
I am going to show how to call TenantMgtAdminService in WSO2 Identity and Access Management (IAM) product in both the above mentioned ways.
Calling TenantMgtAdminService via SoapUI

First you need to allow access to the Admin Services. In order to allow access to the Admin Services, you need to set the following property to false in the carbon.xml in <SERVER_HOME>/repository/conf folder, so that you could be able to access the available list of Admin Services.
<HideAdminServiceWSDLs>false</HideAdminServiceWSDLs>Then start the Server from the OSGI Console by navigating to the <SERVER_HOME>/bin directory and typing the below command (in Linux). If you are using Windows OS, follow the commands accordingly as guided in the WSO2 Documentation.
sh wso2server.sh -DosgiConsoleAfter the server started, you will be getting the OSGI Console and type the following command to list down the Admin Services.
>osgi listAdminServicesIt will list the Admin Services as below, and search for the Admin Service you need.

Here I am using the TenantMgtAdminService. If you want to see the service, you can view it via the below link in your browser.
https://localhost:8243/services/TenantMgtAdminService?wsdlNow you have the Admin Service with you, let’s call it via the SoapUI.
Download and open the SoapUI and create a new SOAP Project by giving TenantMgtAdminService ad the Project Name and https://localhost:8243/services/TenantMgtAdminService?wsdl as the Initial WSDL as below.

Let’s see how to call addTenant method in the TenantMgtAdminService.

Set the Authorization to Basic and add admin and admin as the username and password by clicking Auth tab in the bottom and adding new Authorization type as Basic.


Set the parameters in the request as below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.mgt.tenant.carbon.wso2.org" xmlns:xsd="http://beans.common.stratos.carbon.wso2.org/xsd">
<soapenv:Header/>
<soapenv:Body>
<ser:addTenant>
<!--Optional:-->
<ser:tenantInfoBean>
<!--Optional:-->
<xsd:active>true</xsd:active>
<!--Optional:-->
<xsd:admin>wso2user</xsd:admin>
<!--Optional:-->
<xsd:adminPassword>wso2123</xsd:adminPassword>
<!--Optional:-->
<xsd:email>wso2user@wso2.com</xsd:email>
<!--Optional:-->
<xsd:firstname>wso2</xsd:firstname>
<!--Optional:-->
<xsd:lastname>user</xsd:lastname>
<!--Optional:-->
<xsd:successKey>true</xsd:successKey>
<!--Optional:-->
<xsd:tenantDomain>wso2.com</xsd:tenantDomain>
<!--Optional:-->
<xsd:tenantId>3</xsd:tenantId>
<!--Optional:-->
<xsd:usagePlan>demo</xsd:usagePlan>
</ser:tenantInfoBean>
</ser:addTenant>
</soapenv:Body>
</soapenv:Envelope>Change the endpoint by updating the port as https://localhost:9443/services/TenantMgtAdminService.TenantMgtAdminServiceHttpsSoap11Endpoint
Click send button. Then you will get a response and you have successfully created a tenant via the Admin Service!!!

Calling TenantMgtAdminService via CURL
Create a request.xml file by adding the content as below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.mgt.tenant.carbon.wso2.org" xmlns:xsd="http://beans.common.stratos.carbon.wso2.org/xsd">
<soapenv:Header/>
<soapenv:Body>
<ser:addTenant>
<!--Optional:-->
<ser:tenantInfoBean>
<!--Optional:-->
<xsd:active>true</xsd:active>
<!--Optional:-->
<xsd:admin>wso2user</xsd:admin>
<!--Optional:-->
<xsd:adminPassword>wso2123</xsd:adminPassword>
<!--Optional:-->
<xsd:email>wso2user@wso2.com</xsd:email>
<!--Optional:-->
<xsd:firstname>wso2</xsd:firstname>
<!--Optional:-->
<xsd:lastname>user</xsd:lastname>
<!--Optional:-->
<xsd:successKey>true</xsd:successKey>
<!--Optional:-->
<xsd:tenantDomain>wso2.com</xsd:tenantDomain>
<!--Optional:-->
<xsd:tenantId>3</xsd:tenantId>
<!--Optional:-->
<xsd:usagePlan>demo</xsd:usagePlan>
</ser:tenantInfoBean>
</ser:addTenant>
</soapenv:Body>
</soapenv:Envelope>Now call the TenantMgtAdminService’s addTenant method via CURL as below.
curl -k -H "Content-Type: application/soap+xml;charset=UTF-8;" -H "SOAPAction:urn:addTenant" --basic -u "admin:admin" --data @request.xml https://localhost:9443/services/TenantMgtAdminService.TenantMgtAdminServiceHttpsSoap11EndpointLike wise you can call any method in any WSO2 Admin Service via either SoapUI or CURL.
Happy Coding :)
