File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes JAXWS can not add additional classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAXWS can not add additional classes" Watch "JAXWS can not add additional classes" New topic
Author

JAXWS can not add additional classes

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Hi,

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 Block
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.


SCJP1.4
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
I have tried

@XmlSeeAlso({Image.class, Table.class}) but that does not work.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Tjena!
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.
Best wishes!
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Thanks!

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?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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.
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXWS can not add additional classes