How can I easily deploy and start a service within Apache Axis2, programmatically?

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
  • By Eran Chinthaka
  • 16 Jul, 2007

Step - 1 : Write your service implementation.

 public class StockQuoteService {

public String sayHello(){
return "Hello World";

public String getQuote(String quoteName){
// write your business logic here.
return "SomeQuote";

Step 2 : Compile the service implementation class with debug options on (-g) and use the following code to Deploy it programatically using AxisServer.

  (new AxisServer()).deployService(StockQuoteService.class.getName());

That's it. Your service will be available over port 6060. Try the following URL in the browser : https://localhost:6060/axis2/services/StockQuoteService/sayHello. You will see the following output.

<return>Hello World</return>

Do you also want to pass parameters to a method when you invoke it using the browser? Try invoking getQuote method using the browser, with the following URL : https://localhost:6060/axis2/services/StockQuoteService/getQuote?quoteName=ABC. Notice the quote name ABC that you have passed inside the browser URL. Check your output in the browser.


Applies To

Axis2/Java Latest SVN version as of 18-06-2007 or Axis2 1.3