blogger templates blogger widgets
This is part of a list of blog posts.
To browse the contents go to

Axis 2 webservice notes

Eclipse's Web Tools Platform supports Axis 2.x

1. Download the latest Axis2 runtime from here( and extract it.
2. Now we point Eclipse WTP to downloaded Axis2 Runtime. Open Window -> Preferences -> Web Services -> Axis2 Preferences
Select the Axis2 Runtime tab and point to the correct Axis2 runtime location.

3. Creating webservice

a) Create a dynamic web project. (Axis2Server)
b) In project facets,
Set Dynamic Web Module facet to 2.2, 2.3, 2.4 or 2.5.
If unable to change it edit .settings/org.eclipse.wst.common.project.facet.core.xml file
(this file is displayed in Navigator view)

Set Axis2 Web Services facet.

c) Create service resource



public class HelloOperation {
 public String sayHello(String name){
  return "Hello "+name;
 public MyBean sayBean(){
  MyBean bean = new MyBean();
  InnerBean ibean = new InnerBean();
  ibean.setBeanVal("this is bean value");
  return bean;


public class InnerBean {
 private String beanVal;

 public String getBeanVal() {
  return beanVal;

 public void setBeanVal(String beanVal) {
  this.beanVal = beanVal;

public class MyBean {
 private InnerBean ib;

 public InnerBean getIb() {
  return ib;

 public void setIb(InnerBean ib) {
  this.ib = ib;

d) Select, open File -> New -> Other... -> Web Services -> Web Service
Check server, webservice runtime and service project.

click next.
This page is the service.xml selection page. if you have a custom services.xml, you can include that by clicking the Browse button.
For the moment, just leave it at the default.

Test the deployed webservice endpoint.


4. Creating client

Create a dynamic web project and enable axis2 project facet.
Now we'll generate the client for the newly created service by referring the wsdl generated by the Axis2 Server.
Open File -> New -> Other... -> Web Services -> Web ServiceClient.

Check server/webservice runtime and project selected. All the rest i kept default.

Note that after successful client code generation. You will find a stub and callback handler class in client project.
Try the below code in a main function or servlet method.
HelloOperationStub stub = new HelloOperationStub();
SayHello sayHello = new SayHello();
SayHelloResponse response = stub.sayHello(sayHello);

SayBean temp = new SayBean();

SayBeanResponse response1 = stub.sayBean(temp);

No comments:

Post a Comment