• 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

Resteasy not setting value of element which is also an XmlRootElement

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

My incoming xml has one element called event with some attributes. Resteasy sets the attribute values correctly with annotation @AmlAttribute but it does not set the value of the event which has an @XmlElement annotation.

DocumentName and key get set correctly but event is always null.

I guess the problem may have to do with the fact that the EVENT element is also the XmlRootElement. Is this allowed and how can I make it work


My XML



And my Java class:

 
Saloon Keeper
Posts: 15484
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't really make sense that an Event would contain an event. Does event represent the name of the event? Then you should probably call it name instead.
 
Keimo Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This XML comes from a 3rd party software. I cannot alter it. Or maybe I could alter it in an interceptor or filter if there is no other way. But I'd prefer to do it with standard rest easy if possible.
 
Stephan van Hulst
Saloon Keeper
Posts: 15484
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be clear, the XML looks something like this?
 
Keimo Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would be nice if it had a real root element as in your version. But the XML looks like what I posted. And I need to get all 3 values from it: DocumentName, key and event . . .
 
Stephan van Hulst
Saloon Keeper
Posts: 15484
363
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, I'm sorry, I didn't see your XML sample.

The fix is to use XmlValue instead of XmlElement.
 
Keimo Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works. Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic