Search code examples
web-servicesapache-axispojofault

Axis2 Faulty Pojo Web Service


I have created a pojo as below.

package demo;
public class HelloWorld {
    public String sayHello(String name) {
        return "Hello " + name;
    }
}

I placed it in axis2 war and opened

http://localhost:8080/axis2/services/listServices. 

Axis 2 is indicating it as faulty service

Faulty Services
<TOMCAT-DIR>\webapps\axis2\WEB-INF\pojo\demo\HelloWorld.class

But when I remove package declaration statement and place it on below location, everything works fine

<TOMCAT-DIR>\webapps\axis2\WEB-INF\pojo\HelloWorld.class

Now there are two possibilities

  • Package declaration is not allowed in pojo (and I don't believe this).
  • I am missing something.

Can anyone guide me?


Solution

  • In the book "Apache Axis Web Services, 2nd Edition", author described that when exposing a pojo class as a web service by dropping in into pojo folder, pojo class must be defined in default package.

    When pojo class is defined some package, following link is helpful.

    http://axis.apache.org/axis2/java/core/docs/pojoguide.html

    Thanks to shashankaholic for sharing this link.