Discovering Services Using the Service Discovery Client
Earlier versions of WSO2 G-Reg supported technologies like UDDI and WS-Discovery for discovering services. They are used with SOAP-based services. However, since modern services are mostly REST-based, now WSO2 G-Reg supports REST API and the service discovery client for this capability.
If you have services deployed in the WSO2 Enterprise Service Bus (WSO2 ESB) or WSO2 Enterprise Integrator (WSO2 EI), you can discover them using the service discovery client. This client connects to the WSO2 ESB/EI server and imports the services, which are deployed in them into the G-Reg server after finding them. It imports metadata (endpoint, name, namespace, etc.), WSDLs and XSDs of those services.
Follow the steps below to configure the service discovery client.
- Download WSO2 G-Reg and WSO2 ESB/WSO2 EI products and unzip them.
Apply a port offset in the
<G-REG_HOME>/repository/conf/carbon.xml
file.By default, both servers are running on the 9443 port. Therefore, you have to change either of the server ports.
Copy the
<ESB_HOME>/repository/components/plugins/org.wso2.carbon.service.mgt.stub_4.x.x.jar
file (or the<EI_HOME>/WSO2/components/plugins/org.wso2.carbon.service.mgt.stub_4.x.x.jar
file) to the<G-REG_HOME>/repository/components/dropins
directory.- Download or clone the service discovery client project and build it.
- Copy the built JAR file into the
<G-REG_HOME>/repository/components/dropins
directory. Add the following task under the
<tasks>
element of the<G-REG_HOME>/repository/conf/registry.xml
file, to register the service discovery client as a task.<task name="ServiceDiscovery" class="com.chandana.governance.discovery.services.ServiceDiscoveryTask"> <trigger cron="0/100 * * * * ?" /> <property key="userName" value="admin" /> <property key="password" value="admin" /> <property key="serverUrl" value="https://localhost:9444/services/" /> <property key="version" value="1.0.0" /> </task>
Change the values of the
userName
,password
,serverUrl
andversion
properties in the above configurations according to your setup.- Start WSO2 ESB/EI and then start WSO2 G-Reg.
The Terminal, in which you ran WSO2 G-Reg will print the “# of service created :...
” message once the G-Reg server discovers a service from the WSO2 ESB/EI server. These services will be stored under the SOAP Service asset type in WSO2 G-Reg. Also, you can view the WSDLs and XSDs of the services that are imported into WSO2 G-Reg by the client.