[jbossws-users] [JBossWS] - Re: Customizing XJC invocation?

jyrinx do-not-reply at jboss.com
Thu Apr 17 15:21:16 EDT 2008


"richard.opalka at jboss.com" wrote : "jyrinx" wrote : Is it possible to use XJC plugins with JBoss WS? No :(

Hrm ... that's saddening. Can anyone think of a good hack here?

Well, let me explain the problem: We have a Web service that returns objects of an abstract class. So long as we put @XmlSeeAlso on the superclass, the WSDL comes out fine, and the XML elements have xsi:type attributes, and all is well on the server side. (We're using JBoss WS on both the client and server.)

But then we try out our test client, and we keep getting InstantiationExceptions when JAXB fails to resolve the entities to their concrete subclass and tries to instantiate the abstract superclass. We realized that if we modified the generated code to include @XmlSeeAlso annotations mirroring those on the server side, everything worked. So the question is one of getting those annotations into the client code.

(We could put dummy methods with the concrete subclasses as argument types into the Web service just to force all the subclasses into the JAXBContext, but we'd rather not ...)

So this is all quite solvable with an XJC plugin: It has all the information it needs to write the annotations, and the ideal interface to add them to the generated classes. (The plugin class is about 30 LOC.) If there's some way to get that to work, that would be best. Otherwise, we're going to have to resort to much cruder means of post-processing (or the aforementioned dummy methods).

(There's also this <xjc:substitutable/> thing, but honestly I'm not sure how we'd make use of it: it has to go in the generated schema somehow?)

And besides, there are other very useful XJC plugins - the one that adds toString() methods, for instance, would be very convenient.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4144985#4144985

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4144985



More information about the jbossws-users mailing list