1

I've been using Metro and have come across a problem whereby wsgen seems to ignore any JAXB annotation that I put on web method response classes.

I'm trying to return a set of entity classes that I want to expose to external clients via a web service, however I only want to make certain class attributes and methods visible to external clients, so have set the class access type to be PROPERTY, and have annotated all attributes I want to be part of the XML version of the class with @XmlElement.

I can create the XML schema for the entity class using the schemagen ant task, which correctly ignores any attribute or method that I have not annotated with @XmlElement, however when I run wsgen to create the wsdl for the web service which has a method which returns a set of the entity class, then I get a java.lang.NoClassDefFoundError. This appears to be because wsgen is not ignoring a public method on the entity class that it should do, with the class referenced by the exception being a parameter to this method.

I've tried to annotate the method with @XmlTransient so that wsgen ignores it, but to no avail. If anyone can suggest what I should do to get wsgen to pay attention to my annotations then that would be great.

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79

1 Answers1

0

An annotated field/property will always be processed regardless of accessor type. You need to specify @XmlAccessorType(XmlAccessType.NONE) if you only want annotated fields/properties to be treated as mapped.

For More Information

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Thanks for the suggestion Blaise, however even if I change the accessor type to NONE then running wsgen still complains regarding a class which is a parameter for a method which should be ignored but for some reason isnt. I'm a bit confused as running schemagen produces a valid xml schema for the entity class which pays attention to my annotation, but it seems that wsgen must have its own method for creating schemas which seems to ignore my annotation – user1872413 Dec 03 '12 at 12:21