aspose file tools*
The moose likes XML and Related Technologies and the fly likes JAXB annotation problem/question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB annotation problem/question" Watch "JAXB annotation problem/question" New topic
Author

JAXB annotation problem/question

Bob Peterson
Ranch Hand

Joined: Jul 30, 2004
Posts: 47
I'm not sure which forum is better for this question, this one or WebServices, since I'm running into this problem while using Apache CXF. But the core problem is with JAXB annotations.

I'm trying to eventually get my response to be a simple list of items, like so:



And here are my classes



I had to create the OrdMedList class because without it, the service interface was initially returning an array of OrdMeds, but there was no <OrdMedList> tag, even though I had a @WebResult(name="OrdMedList") annotation on that. I read that this was a problem with JAXB, and was recommended to create the OrdMedList class.

So now the problem is that the result xml is



I guess it grabs that 'ordMeds' name from the property of the OrdMedList class. So I tried annotating that with the @XmlElement(name="OrdMed") but that created a JAXB error that said:

IllegalAnnotationExceptions
Class has 2 properties of the same name "ordMeds"
this problem is related to the following location:
at public java.util.List com.test.services.OrdMedList.getOrdMeds()
at com.test.services.OrdMedList
this problem is related to the following location:
at public java.util.List com.test.services.OrdMedList.ordMeds
at com.test.services.OrdMedList

How can I get the response formatted the way I want? Seems like this is much harder than it should be.

Thanks
 
Consider Paul's rocket mass heater.
 
subject: JAXB annotation problem/question