I’m trying to set up a web service.
My approach has been:
- create Dynamic Web Project
-
create class “MyService”:
@WebService @XmlSeeAlso({B.class}) public class MyService { public A method() { return new B(); } } -
create class “A”:
@XmlSeeAlso(B.class) public class A { public int propertyOfA=0; } -
create class “B”:
public class B extends A { public int propertyOfB=1; } -
Create Web Service from MyService.java
There are no errors, all the files get created. However, the class B does not appear anywhere in the WSDL. Consequently, all web service responses never contain any values for propertyOfB, as it’s not in the service description.
How do I get B into the WSDL?
edit: I’m not sure if it makes any difference, but I’m creating the web service for Tomcat v7.0, Apache Axis
I think your requirement is to inform the user of the web service that B type object can also be returned form the method() operation. So what you have to do is adding a entry like this to your service.xml,
So it will add entries to WSDL mentioning the web service operation will return these kind of object also. So when code-gen happens these are also generated. You can find which class is returned by checking the xsi:type of the response. Please read this blog for further understanding, http://ssagara.blogspot.com/2011/07/how-to-get-best-use-of-axis2-object.html