Announcement Announcement Module
Collapse
No announcement yet.
REST spring 3.1 returns HTTP Status 406 XML marshalling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • REST spring 3.1 returns HTTP Status 406 XML marshalling

    Hello,

    I've a controller that return a object. Convert to XML with the Xstream marshaller.
    I tryed also with headers = { "Accept=application/xml, text/xml" }, but it always give me the following error in the browser:

    URL in browser:
    http://localhost:8080/qConfig/spring/rest/project/1

    give following error. I have no idea what the problem is. Any idea?

    HTTP Status 406
    The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.




    applicationcontext.xml
    Code:
        <bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"/>
        <bean id="marshallingHttpMessageConverter"
              class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
            <property name="marshaller" ref="xstreamMarshaller"/>
            <property name="unmarshaller" ref="xstreamMarshaller"/>
        </bean>
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
            <property name="messageConverters">
                <util:list id="beanList">
                    <ref bean="marshallingHttpMessageConverter"/>
                </util:list>
            </property>
        </bean>
    ControllerCode
    Code:
      @RequestMapping(value = "/rest/project/{id}", method = RequestMethod.GET)
      @ResponseBody
      public QProject findProject(@PathVariable(value = "id")
      Long id) {
        
        QProject qProject = this.projectRepository.findOne(id);
       
        
        return qProject;
      }
    Last edited by BartP; Nov 15th, 2012, 05:57 AM.
Working...
X