Results 1 to 1 of 1

Thread: REST spring 3.1 returns HTTP Status 406 XML marshalling

  1. #1
    Join Date
    Nov 2012
    Posts
    11

    Default 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 at 04:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •