WSO2Con 2013 CFP Banner

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.
Discuss this article on Stack Overflow
By Eran Chinthaka
  • 16 Jul, 2007
  • Level:  Introductory
  • Reads: 3726

Axis2 comes with a cool feature that enables you to deploy your simple service implementation class.

Eran Chinthaka
Software Engineer
WSO2 Inc.

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 : http://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 : http://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