• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAXB annotation problem/question

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic