java - Polymorphism in JAX-RPC web services -
i have jax-rpc (java) web service needs return complex polymorphic value. more specific, class structure this:
abstract class child { } class question extends child { private string name; // other fields, getters, , setters } class section extends child { private string label; private child[] children; // getters , setters } class quiz { private child[] elements; // getter , setter }
my web service has method returns quiz, of course may contain questions , sections may contain questions , other sections, , on , forth. however, when generate wsdl, child , quiz make in. when call web service, quiz element right number of children, they're child elements, , they're empty.
is there way make work, short of returning xml string?
before asks, due circumstances beyond control, cannot use jax-ws.
i don't think jax-rpc supports polymorphism in way. had similar problem, , had work around creating class had 2 members - 1 each of 2 classes possibly returned - , populating 1 depending on type wanted return. in case:
class child { private section section; private question question; // constructor, etc... } class question { private string name; // other fields, getters, , setters } class section { private string label; private child[] children; // getters , setters } class quiz { private child[] elements; // getter , setter }
which requires client check member of child populated, , horribly ugly, know.
Comments
Post a Comment