Reputation: 291
I am trying to add a tenant in WSO2 programmatically using java (i.e without using the API Manager console). I tried using "RemoteTenantManagerService" in the Admin Services but it gives an error:
org.apache.axis2.AxisFault: org.wso2.carbon.user.core.UserStoreException: Error in adding tenant with tenant domain: test.com
I enabled debug logs and found:
{org.wso2.carbon.user.core.tenant.TenantManager} - Error in adding tenant with tenant domain: test.com. {org.wso2.carbon.user.core.tenant.TenantManager} java.lang.NullPointerException at org.wso2.carbon.user.core.config.RealmConfigXMLProcessor.serialize(RealmConfigXMLProcessor.java:72) at org.wso2.carbon.user.core.tenant.JDBCTenantManager.addTenant(JDBCTenantManager.java:109) at org.wso2.carbon.um.ws.service.TenantManagerService.addTenant(TenantManagerService.java:41)
Any suggestions?
Upvotes: 1
Views: 720
Reputation: 291
I am able to resolve the issue using the service "TenantMgtAdminService" while adding tenant programatically. Tenant details can be set in "TenantInfoBean" and added as - TenantMgtAdminServiceStub.addTenant(TenantInfoBean).
Imports are: org.wso2.carbon.tenant.mgt.stub.TenantMgtAdminServiceStub and org.wso2.carbon.tenant.mgt.stub.beans.xsd.TenantInfoBean.
Cheers!! :)
Upvotes: 2
Reputation: 1009
Please try using https://localhost:9443/services/TenantMgtService?wsdl as you WSDL
Note: Before using admin services you need to set
<HideAdminServiceWSDLs>false</HideAdminServiceWSDLs> in carbon.xml
(file located at: /repository/conf/carbon.xml
My sample soap envelop is given 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:registerTenantForTrustedUser>
<ser:tenantInfoBean>
<xsd:active>true</xsd:active>
<xsd:admin>admin</xsd:admin>
<xsd:adminPassword>admin</xsd:adminPassword>
<xsd:email>[email protected]</xsd:email>
<xsd:firstname>Channa</xsd:firstname>
<xsd:lastname>E</xsd:lastname>
<xsd:tenantDomain>abc.test.com</xsd:tenantDomain>
<xsd:tenantId>-1</xsd:tenantId>
</ser:tenantInfoBean>
</ser:registerTenantForTrustedUser>
</soap:Body>
</soap:Envelope>
With above I was able to successfully create a tenant
Upvotes: 0