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. In this example i will specifically focus on axis2 services and discuss how to create service repository for axis 2 services.
Here is the detailed flow.
- In jenkins(or any other task scheduler to check available services frequentrly) we will deployed scheduled task to trigger some event periodically.
- Periodic task will call WSO2 App Server’s admin services to get service metadata. To list service meta data for axis2 services we can call service admin soap service (https://127.0.0.1:9443/services/ServiceAdmin?wsdl)
- In same way we can call all services and get complete service data(if you need other service types in addition to axis2 services).
If we consider proxy service details then we can follow approach listed below.
Create web service client for https://127.0.0.1:9443/services/ServiceAdmin?wsdl service and invoke it from client. See following Soapui sample to get all proxy services deployed in ESB.
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="ax2356:ServiceMetaDataWrapper"
xmlns:ax2356="http://mgt.service.carbon.wso2.org/xsd"
xmlns:ax2358="http://neethi.apache.org/xsd" xmlns:ax2359="http://util.java/xsd"
xmlns:ax2354="http://utils.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax2356:numberOfActiveServices>4</ax2356:numberOfActiveServices>
<ax2356:numberOfCorrectServiceGroups>4</ax2356:numberOfCorrectServiceGroups>
<ax2356:numberOfFaultyServiceGroups>0</ax2356:numberOfFaultyServiceGroups>
<ax2356:numberOfPages>1</ax2356:numberOfPages>
<ax2356:serviceTypes>axis2</ax2356:serviceTypes>
<ax2356:serviceTypes>js_service</ax2356:serviceTypes>
<ax2356:services xsi:type="ax2356:ServiceMetaData">
<ax2356:active>true</ax2356:active>
<ax2356:description xsi:nil="true"/>
<ax2356:disableDeletion>false</ax2356:disableDeletion>
<ax2356:disableTryit>false</ax2356:disableTryit>
<ax2356:eprs xsi:nil="true"/>
<ax2356:foundWebResources>false</ax2356:foundWebResources>
<ax2356:mtomStatus xsi:nil="true"/>
<ax2356:name>echo</ax2356:name>
<ax2356:operations xsi:nil="true"/>
<ax2356:scope xsi:nil="true"/>
<ax2356:securityScenarioId xsi:nil="true"/>
<ax2356:serviceDeployedTime>1970-01-01 05:30:00</ax2356:serviceDeployedTime>
<ax2356:serviceGroupName>Echo</ax2356:serviceGroupName>
<ax2356:serviceId xsi:nil="true"/>
<ax2356:serviceType>axis2</ax2356:serviceType>
<ax2356:serviceUpTime>17023day(s) 6hr(s) 16min(s)</ax2356:serviceUpTime>
<ax2356:serviceVersion xsi:nil="true"/>
<ax2356:tryitURL>http://172.17.0.1:9763/services/echo?tryit</ax2356:tryitURL>
<ax2356:wsdlPortTypes xsi:nil="true"/>
<ax2356:wsdlPorts xsi:nil="true"/>
<ax2356:wsdlURLs>http://172.17.0.1:9763/services/echo?wsdl</ax2356:wsdlURLs>
<ax2356:wsdlURLs>http://172.17.0.1:9763/services/echo?wsdl2</ax2356:wsdlURLs>
</ax2356:services>
<ax2356:services xsi:type="ax2356:ServiceMetaData">
<ax2356:active>true</ax2356:active>
<ax2356:description xsi:nil="true"/>
<ax2356:disableDeletion>false</ax2356:disableDeletion>
<ax2356:disableTryit>false</ax2356:disableTryit>
<ax2356:eprs xsi:nil="true"/>
<ax2356:foundWebResources>false</ax2356:foundWebResources>
<ax2356:mtomStatus xsi:nil="true"/>
<ax2356:name>HelloService</ax2356:name>
<ax2356:operations xsi:nil="true"/>
<ax2356:scope xsi:nil="true"/>
<ax2356:securityScenarioId xsi:nil="true"/>
<ax2356:serviceDeployedTime>1970-01-01 05:30:00</ax2356:serviceDeployedTime>
<ax2356:serviceGroupName>HelloWorld</ax2356:serviceGroupName>
<ax2356:serviceId xsi:nil="true"/>
<ax2356:serviceType>axis2</ax2356:serviceType>
<ax2356:serviceUpTime>17023day(s) 6hr(s) 16min(s)</ax2356:serviceUpTime>
<ax2356:serviceVersion xsi:nil="true"/>
<ax2356:tryitURL>http://172.17.0.1:9763/services/HelloService?tryit</ax2356:tryitURL>
<ax2356:wsdlPortTypes xsi:nil="true"/>
<ax2356:wsdlPorts xsi:nil="true"/>
<ax2356:wsdlURLs>http://172.17.0.1:9763/services/HelloService?wsdl</ax2356:wsdlURLs>
<ax2356:wsdlURLs>http://172.17.0.1:9763/services/HelloService?wsdl2</ax2356:wsdlURLs>
</ax2356:services>
<ax2356:services xsi:type="ax2356:ServiceMetaData">
<ax2356:active>true</ax2356:active>
<ax2356:description xsi:nil="true"/>
<ax2356:disableDeletion>false</ax2356:disableDeletion>
<ax2356:disableTryit>false</ax2356:disableTryit>
<ax2356:eprs xsi:nil="true"/>
<ax2356:foundWebResources>false</ax2356:foundWebResources>
<ax2356:mtomStatus xsi:nil="true"/>
<ax2356:name>Version</ax2356:name>
<ax2356:operations xsi:nil="true"/>
<ax2356:scope xsi:nil="true"/>
<ax2356:securityScenarioId xsi:nil="true"/>
<ax2356:serviceDeployedTime>1970-01-01 05:30:00</ax2356:serviceDeployedTime>
<ax2356:serviceGroupName>Version</ax2356:serviceGroupName>
<ax2356:serviceId xsi:nil="true"/>
<ax2356:serviceType>axis2</ax2356:serviceType>
<ax2356:serviceUpTime>17023day(s) 6hr(s) 16min(s)</ax2356:serviceUpTime>
<ax2356:serviceVersion xsi:nil="true"/>
<ax2356:tryitURL>http://172.17.0.1:9763/services/Version?tryit</ax2356:tryitURL>
<ax2356:wsdlPortTypes xsi:nil="true"/>
<ax2356:wsdlPorts xsi:nil="true"/>
<ax2356:wsdlURLs>http://172.17.0.1:9763/services/Version?wsdl</ax2356:wsdlURLs>
<ax2356:wsdlURLs>http://172.17.0.1:9763/services/Version?wsdl2</ax2356:wsdlURLs>
</ax2356: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.
No comments:
Post a Comment