2007/07/16
16 Jul, 2007

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

  • Eran Chinthaka
  • Software Engineer - WSO2

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.

<ns:sayHelloResponse>
<return>Hello World</return>
</ns:sayHelloResponse>

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.

  <ns:getQuoteResponse>
<return>SomeQuote</return>
</ns:getQuoteResponse>
 

Applies To

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

 

About Author

  • Eran Chinthaka
  • Software Engineer
  • WSO2 Inc.