File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB annotation problem/question" Watch "JAXB annotation problem/question" New topic

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:

Class has 2 properties of the same name "ordMeds"
this problem is related to the following location:
at public java.util.List
this problem is related to the following location:
at public java.util.List

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

I agree. Here's the link:
subject: JAXB annotation problem/question
jQuery in Action, 3rd edition