I'm trying to get an object parsed from XML (request body). My controller method's header is
public ModelAndView differentTypeOfIds(@RequestBody DiffIdsRequest.DescBatch body){
where DescBatch is static inner class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"descBatch"
})
@XmlRootElement(name = "diffIdsRequest")
public class DiffIdsRequest {
@XmlElement(name = "desc-batch", required = true)
protected DiffIdsRequest.DescBatch descBatch;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"descItem"
})
public static class DescBatch {
A snippet of servlet configuration
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="eu.eudml.restModel.DiffIdsRequest$DescBatch" />
</oxm:jaxb2-marshaller>
In logs I can see line
2012-07-31 17:34:11,604 [] [pool-2-thread-1] INFO o.s.oxm.jaxb.Jaxb2Marshaller - Creating JAXBContext with clas ses to be bound [class eu.eudml.restModel.DiffIdsRequest$DescBatch]
It seems to be ok, but when I'm sending some data (xml without any namespaces) method differentTypeIds isn't called. ModelAndView is null (logs).
Are there any problems with inner class or anything else?
You seem to be missing @XmlRootElement
or @XmlType
on DescBatch
. Also, you have to ensure that an Accept header of application/xml
is sent as part of the request.