Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Resteasy not setting value of element which is also an XmlRootElement  RSS feed

 
Keimo Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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:

 
Stephan van Hulst
Saloon Keeper
Posts: 6969
109
  • Mark post as helpful
  • send pies
  • 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
  • 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: 6969
109
  • Mark post as helpful
  • send pies
  • 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
  • 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: 6969
109
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Works. Thanks.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!