I wish to catch an XML (HashMap) of this format in my POST handler
<entries>
<entry>
<id>1</id>
<labels>
<label>label1</label>
<label>label2</label>
...
</labels>
<entry>
...
<entries>
I wish my POST handler using Apache Jersey to look like this
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void createEntries(@MagicAnnotation HashMap<id, List<label>> entryMap){
}
What is the closest I can get to this?
I am open to a better representation of a HashMap to XML. I just don’t wish to parse xml manually and want to catch equivalent JSON as well.
I am not sure if some JAXBElement can be used instead of jersey annotation.
Your are not supposed to access the POST body this way.
You have to define several classes to let Jersey parse the XML response.
Your code will look like:
To make this work Entries have to be JAXB compatible:
Ah, and Jersey is not from Apache but from Sun.