[WSO2] Start stop services by command line

When services are deployed to WSO2 Application Server, or when we create proxy services in WSO2 ESB, as soon as they are deployed they are active and ready to serve requests. Some times you might need to disable them maybe to upgrade the services, maybe as a new version of the service is available etc.

The Management Console of WSO2 Application Server and WSO2 ESB provide this facility.

When you automate the deployments and configure them you need a command-line way to perform enabling and disabling services. WSO2 has exposed this functionalities as SOAP that we can leverage.

We can use following Admin Service

https://127.0.0.1:9443/services/ServiceAdmin


Stop a service  

Let us stop the "echo" service that come by default in Application Server. 


  •  create a xml file called stopRequest.xml and save the following content into it. Pass the service name that should be stopped

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:stopService>
         <!--Optional:-->
         <xsd:serviceName>echo</xsd:serviceName>
      </xsd:stopService>
   </soapenv:Body>
</soapenv:Envelope>


      Issue the following curl command with appropriate credentials, host and ports. 


curl -k -u admin:admin --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:stopService" --data @stopRequest.xml https://127.0.0.1:9443/services/ServiceAdmin




Start a service 


  • create a xml file called startRequest.xml and save the following content into it. Pass the service name that should be started. 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://org.apache.axis2/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <xsd:startService>
         <!--Optional:-->
         <xsd:serviceName>echo</xsd:serviceName>
      </xsd:startService>
   </soapenv:Body>
</soapenv:Envelope>


  • Issue the following curl command with appropriate credentials, host and ports

curl -k -u admin:admin --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:startService" --data @startRequest.xml https://127.0.0.1:9443/services/ServiceAdmin

Hasitha Hiranya

No comments:

Post a Comment

Instagram