Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:51:42+00:00 2026-05-29T16:51:42+00:00

I wrote an abstract class import javax.xml.bind.annotation.*; public abstract class Parent { @XmlAttribute(name =

  • 0

I wrote an abstract class

import javax.xml.bind.annotation.*;
public abstract class Parent
    {
    @XmlAttribute(name = "one")
    public String getOne() { return "one";}
    }

and two derived classes:

import javax.xml.bind.annotation.*;
@XmlRootElement(name="child1")
public class Child1 extends Parent
    {
    @XmlAttribute(name = "two")
    public String getTwo() { return "2";}
    }



import javax.xml.bind.annotation.*;
@XmlRootElement(name="child2")
public class Child2 extends Parent
    {
    @XmlAttribute(name = "three")
    public String getThree() { return "3";}
    }

and a @webservice:

import javax.xml.ws.Endpoint;
import javax.jws.*;
import java.util.*;

@WebService(serviceName="MyServerService", name="MyServer")
public class MyServer
    {
        private int count=0;
    @WebResult(name="test")
        @WebMethod
    public Parent getOne() { return ++count%2==0?new Child1():new Child2();}

    public static void main(String[] args) {

      Endpoint.publish(
            "http://localhost:8080/path",
            new MyServer());

        }
    }

When the code is generated using wsgen, the resulting XML schema only contains the definition for the abstract class Parent but not for Child1 or Child2. Is there any way to tell wsgen to generate the definition for the two concrete classes ?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:51:46+00:00Added an answer on May 29, 2026 at 4:51 pm

    Adding an annotation @XmlSeeAlso should do the trick:

    @XmlSeeAlso({Child1.class, Child2.class})
    public abstract class Parent {
        @XmlAttribute(name = "one")
        public String getOne() { 
           return "one";
        }
    }
    

    If you prefer not to make parent class aware of its subclasses you can put that annotation on the WS level as well:

    @WebService(serviceName="MyServerService", name="MyServer")
    @XmlSeeAlso({Child1.class, Child2.class})
    public class MyServer {
        private int count=0;
    
        @WebResult(name="test")
        @WebMethod
        public Parent getOne() { 
            return ++count%2==0?new Child1():new Child2();
        }
    
        public static void main(String[] args) {
            Endpoint.publish("http://localhost:8080/path", new MyServer());
        }
    }
    

    Interesting information about this behavior you can find here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have wrote the following polymorphic code: public abstract class A { readonly int
I wrote an abstract class to contain all rules of the application because I
I wrote a non-static Generic class instantiator for my Abstract Factory design, and use
I have this class: public abstract class Directory { protected int id; protected File
If I have following type hierarchy: abstract class TicketBase { public DateTime PublishedDate {
Given the following code : package core; public abstract class GeometricElement { private float
public abstract class ContentManagedEntity { public Guid Guid { get; set; } public bool
I wrote a simple tool to generate a DBUnit XML dataset using queries that
I wrote a class that allows a derivate to specify which of its properties
I have an abstract class Moveable with the method abstract void move() which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.