Spring mvc based rest service throws Http 415 for XML input

djbigtyme

New Member
I have a spring mvc based rest service, the GET request works fine. I get a XML response.I have a problem with the POST request.It throws a Http 415 : "The server refused this request because the request entity is in a format not supported by the requested resource for the requested method ()"I am using JAXB.My controller code:\[code\] @RequestMapping(value="http://stackoverflow.com/product",method= RequestMethod.POST,headers="content-type=application/xml")public @ResponseBody Boolean createProduct(@RequestBody Product product ){ return service.createProduct(product);}\[/code\]The product class :\[code\] @Entity @XmlRootElement @Table(name="PRODUCT") public class Product implements Serializable{ private static final long serialVersionUID = -1100231118908553703L; private Long productId; private String productName; @Id @Column(name="PRODUCTID",nullable=false) public Long getProductId() { return productId; } public void setProductId(Long productId) { this.productId = productId; } @Column(name="PRODUCTNAME") public String getProductName() { return productName; } public void setProductName(String productName) { this.productName = productName; } }\[/code\]The following are the mappings in the context file:\[code\]<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters" ref="marshallingHttpMessageConverter" /></bean><bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter" id="marshallingHttpMessageConverter"> <property name="marshaller" ref="jaxb" /> <property name="unmarshaller" ref="jaxb" /></bean><oxm:jaxb2-marshaller id="jaxb"> <oxm:class-to-be-bound name="com.test.data.Product" /> <oxm:class-to-be-bound name="com.test.data.ProductFamily" /></oxm:jaxb2-marshaller>\[/code\]I am totally blocked by this. If anybody has seen this before please help me by telling me what I am missing.Thanks in advance !
 
Back
Top