How to Create Service Metadata Repository for WSO2 Products(WSO2 ESB, DSS, AS)


Sometimes we need to store all service metadata in single place and maintain changes, life cycles etc. To address this we can implement this as automated process.
Here is the detailed flow.
  • In jenkins we will deployed scheduled task to trigger some event periodically.
  • Periodic task will call WSO2 ESB, DSS and App Server’s admin services to get service metadata. In ESB we can call proxy service admin service to list app proxy services deployed in ESB. From same call we can get WSDLs associated with services. Please refer this article for more information about admin services and how we can use them.
  • In same way we can call all services and get complete service data.
  • Then we can call registry rest API and push that information.  Please refer this article for more information about Registry REST API.  

If we consider proxy service details then we can follow approach listed below.
Create web service client for https://127.0.0.1:9444/services/ServiceAdmin service and invoke it from client.
See following Soapui sample to get all proxy services deployed in ESB.

Screenshot from 2016-06-17 11-50-59.png


You will see response like below. There you will all details related to given proxy service such as wsdls, service status, service type etc. So you can list all service metadata using the information we retrieved from this web service call.


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Body>
    <ns:listServicesResponse xmlns:ns="http://org.apache.axis2/xsd">
       <ns:return xsi:type="ax2539:ServiceMetaDataWrapper" xmlns:ax2541="http://neethi.apache.org/xsd" 
xmlns:ax2539="http://mgt.service.carbon.wso2.org/xsd" 
xmlns:ax2542="http://util.java/xsd" xmlns:ax2545="http://utils.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <ax2539:numberOfActiveServices>5</ax2539:numberOfActiveServices>
          <ax2539:numberOfCorrectServiceGroups>5</ax2539:numberOfCorrectServiceGroups>
          <ax2539:numberOfFaultyServiceGroups>0</ax2539:numberOfFaultyServiceGroups>
          <ax2539:numberOfPages>1</ax2539:numberOfPages>
          <ax2539:serviceTypes>axis2</ax2539:serviceTypes>
          <ax2539:serviceTypes>proxy</ax2539:serviceTypes>
          <ax2539:serviceTypes>sts</ax2539:serviceTypes>
          <ax2539:services xsi:type="ax2539:ServiceMetaData">
             <ax2539:CAppArtifact>false</ax2539:CAppArtifact>
             <ax2539:active>true</ax2539:active>
             <ax2539:description xsi:nil="true"/>
             <ax2539:disableDeletion>false</ax2539:disableDeletion>
             <ax2539:disableTryit>false</ax2539:disableTryit>
             <ax2539:eprs xsi:nil="true"/>
             <ax2539:foundWebResources>false</ax2539:foundWebResources>
             <ax2539:mtomStatus xsi:nil="true"/>
             <ax2539:name>testproxy</ax2539:name>
             <ax2539:operations xsi:nil="true"/>
             <ax2539:scope xsi:nil="true"/>
             <ax2539:securityScenarioId xsi:nil="true"/>
             <ax2539:serviceDeployedTime>1970-01-01 05:30:00</ax2539:serviceDeployedTime>
             <ax2539:serviceGroupName>testproxy</ax2539:serviceGroupName>
             <ax2539:serviceId xsi:nil="true"/>
             <ax2539:serviceType>proxy</ax2539:serviceType>
             <ax2539:serviceUpTime>16969day(s) 6hr(s) 20min(s)</ax2539:serviceUpTime>
             <ax2539:serviceVersion xsi:nil="true"/>
             <ax2539:tryitURL>/services/testproxy?tryit</ax2539:tryitURL>
             <ax2539:wsdlPortTypes xsi:nil="true"/>
             <ax2539:wsdlPorts xsi:nil="true"/>
             <ax2539:wsdlURLs>http://sanjeewa-ThinkPad-X1-Carbon-3rd:8281/services/testproxy?wsdl</ax2539:wsdlURLs>
             <ax2539:wsdlURLs>http://sanjeewa-ThinkPad-X1-Carbon-3rd:8281/services/testproxy?wsdl2</ax2539:wsdlURLs>
          </ax2539:services>
          <ax2539:services xsi:type="ax2539:ServiceMetaData">
             <ax2539:CAppArtifact>false</ax2539:CAppArtifact>
             <ax2539:active>true</ax2539:active>
             <ax2539:description xsi:nil="true"/>
             <ax2539:disableDeletion>false</ax2539:disableDeletion>
             <ax2539:disableTryit>false</ax2539:disableTryit>
             <ax2539:eprs xsi:nil="true"/>
             <ax2539:foundWebResources>false</ax2539:foundWebResources>
             <ax2539:mtomStatus xsi:nil="true"/>
             <ax2539:name>testp</ax2539:name>
             <ax2539:operations xsi:nil="true"/>
             <ax2539:scope xsi:nil="true"/>
             <ax2539:securityScenarioId xsi:nil="true"/>
             <ax2539:serviceDeployedTime>1970-01-01 05:30:00</ax2539:serviceDeployedTime>
             <ax2539:serviceGroupName>testp</ax2539:serviceGroupName>
             <ax2539:serviceId xsi:nil="true"/>
             <ax2539:serviceType>proxy</ax2539:serviceType>
             <ax2539:serviceUpTime>16969day(s) 6hr(s) 20min(s)</ax2539:serviceUpTime>
             <ax2539:serviceVersion xsi:nil="true"/>
             <ax2539:tryitURL>/services/testp?tryit</ax2539:tryitURL>
             <ax2539:wsdlPortTypes xsi:nil="true"/>
             <ax2539:wsdlPorts xsi:nil="true"/>
      <ax2539:wsdlURLs>http://sanjeewa-ThinkPad-X1-Carbon-3rd:8281/services/testp?wsdl</ax2539:wsdlURLs>
    <ax2539:wsdlURLs>http://sanjeewa-ThinkPad-X1-Carbon-3rd:8281/services/testp?wsdl2</ax2539:wsdlURLs>
          </ax2539:services>
       </ns:return>
    </ns:listServicesResponse>
 </soapenv:Body>
</soapenv:Envelope>

We can automate this service metadata retrieving process and persist it to registry. Please refer below diagram to understand flow for this use case. Discovery agent will communicate with servers and use REST client to push events to registry.

Untitled drawing(1).jpg

No comments:

Post a Comment

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...