I'm trying to generate a webservice client in eclipse. I have developed a Web Service with jax ws and everything works fine except for the following.
My dto are inherited like this.
class Image extends Block
class Table extends Block
The web service method returns Block and I check instance of in my client. The problem is that the Image class is not included in the wsdl since the webservice method returns the class Block. How can I include the Image, Table in the generated classes.
Have you tried to define all the types in the XML schema and use XML inheritance, like in the following example:
In the example, the type Policeman extends the type Person. If you then use the JAXB binding compiler (XJC), which is automagically used when you invoke wsimport to generate client artifacts, then you will get a Policeman class that extends a Person class.
Mathias Nilsson wrote:
But I thought that I could do this without the wsdl. I use jax-ws annotations.
I use the spring-xfire to make the magic happen. Is there anyway I can include classes with annotations?
XML schemas can still be used, without having to be included in a WSDL, to generate JAXB bean classes for the request and response.
I personally prefer to write an XML schema and generate the JAXB classes using XJC, but of course you can do it the other way too, but I have no experience with that approach.
Here is what I would do if I were in your situation (if I wanted to do bean-classes-first development):
- Write an XML schema that comes relatively close to the data model you have now.
- Use XJC to generate JAXB bean classes from the XML schema.
- See how the JAXB bean classes are annotated with JAXB annotations and try to apply this to my existing classes.
- Annotate the method(s) I want to use my custom request and/or response beans with RequestWrapper and/or ResponseWrapper annotations.