Friday, March 4, 2016

Get the CarbonApplication list and Deployed artifacts using the Admin services in WSO2 ESB

WSO2 products are managed internally using SOAP Web services known as admin services. Management console uses the Admin Service to facilitate administration capabilities through the UI.
So every activity done through the Management console can be achieved using the Admin services.
Using those Admin services, we can list the installed CarbonApplications with their versions. Also, we can get the artifact list in each Carbonapplication separately.

We need to follow the below steps to enable admin service in the ESB. More details available in this document [1]

1) Set the <HideAdminServiceWSDLs> element to false in the <PRODUCT_HOME>/repository/conf/carbon.xml file.
2) Restart the server.

The adminservices related to the Carbonapplications available in following WSDL.

https://localhost:9443/services/ApplicationAdmin?wsdl

We can check this by calling the above URL in a browser. We can simply call this admin service using the SOAP UI.

Create a new SOAP project in the SOAP UI, using the above WSDL link. Then you will find the project like below [2].



Please use the serverlet port to invoke the adminservices. In our case, we used the offset value as 0. so our serverlet port is 9443.





Using the "listAllApplication" method you can get all the current installed CarbonApplicaions.
Using the "getAppData" method youcan retrieve the CarbonApplication and its artifacts separetely.
Following is sample request, I tested.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mgt="http://mgt.application.carbon.wso2.org">
   <soapenv:Header/>
   <soapenv:Body>
      <mgt:getAppData>
         <!--Optional:-->
         <mgt:appName>asdsd_1.0.0</mgt:appName>
      </mgt:getAppData>
   </soapenv:Body>
</soapenv:Envelope>

The response I received.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns:getAppDataResponse xmlns:ns="http://mgt.application.carbon.wso2.org">
         <ns:return xsi:type="ax23:ApplicationMetadata" xmlns:ax23="http://mgt.application.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <ax23:appName>asdsd</ax23:appName>
            <ax23:appVersion>1.0.0</ax23:appVersion>
            <ax23:artifactsDeploymentStatus xsi:type="ax23:ArtifactDeploymentStatus">
               <ax23:artifactName>simpleProxy</ax23:artifactName>
               <ax23:deploymentStatus>Deployed</ax23:deploymentStatus>
            </ax23:artifactsDeploymentStatus>
         </ns:return>
      </ns:getAppDataResponse>
   </soapenv:Body>
</soapenv:Envelope>


[1] https://docs.wso2.com/display/ESB481/Calling+Admin+Services+from+Apps
[2] http://charithaka.blogspot.com/2013/06/invoking-wso2-carbon-admin-services.html


No comments :

Post a Comment