Results 1 to 2 of 2

Thread: no suitable HttpMessageConverter found for response type

  1. #1
    Join Date
    Nov 2012
    Posts
    11

    Default no suitable HttpMessageConverter found for response type

    Hello,

    I get this exception on the Android site using RestTemplate.


    Caused by: org.springframework.web.client.RestClientException : Could not extract response: no suitable HttpMessageConverter found for response type [com.tck.gia.resthome.shared.dto.MenuDTO] and content type [application/xml]

    The servercode is like this(Controller):
    Code:
      @RequestMapping(value = "/menu", method = RequestMethod.GET)
      @ResponseBody
      public  MenuDTO findMenu() {
        Menu menu = restService.findActiveMenu();
        if (menu != null) {
          return menu.getMenuDTO();
        }
        return null;
      }
    What is the default marshaller?

    On my android app I use this code:

    Code:
    url = new URI(StartUp.GIA_SERVER_URL + "/GiaRestHome/rest/menu/");
          RestTemplate restTemplate = new RestTemplate();
          restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
          restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());
          restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
          restTemplate.getMessageConverters().add(new FormHttpMessageConverter());
          menuDTO = restTemplate.getForObject(url, MenuDTO.class);
    I don't understand wich default converter is used. When I go directly to the browser I see this:

    HTML Code:
    <com.tck.gia.resthome.shared.dto.MenuDTO>
    <id>1</id>
    <description>TestMenu</description>
    <activated>true</activated>
    <enabled>true</enabled>
    <mainCategories>
    <com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
    <id>1</id>
    <description>Lunch</description>
    <subCategories>
    <com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
    <id>1</id>
    <description>Vegetarisch</description>
    <dishes>
    <com.tck.gia.resthome.shared.dto.MenuDishDTO>
    <id>1</id>
    <description>Bloemkool</description>
    </com.tck.gia.resthome.shared.dto.MenuDishDTO>
    <com.tck.gia.resthome.shared.dto.MenuDishDTO>
    <id>2</id>
    <description>Sla</description>
    </com.tck.gia.resthome.shared.dto.MenuDishDTO>
    </dishes>
    </com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
    </subCategories>
    </com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
    <com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
    <id>2</id>
    <description>Diner</description>
    <subCategories>
    <com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
    <id>2</id>
    <description>Vlees</description>
    <dishes>
    <com.tck.gia.resthome.shared.dto.MenuDishDTO>
    <id>3</id>
    <description>Biefstuk</description>
    </com.tck.gia.resthome.shared.dto.MenuDishDTO>
    </dishes>
    </com.tck.gia.resthome.shared.dto.MenuSubCategoryDTO>
    </subCategories>
    </com.tck.gia.resthome.shared.dto.MenuMainCategoryDTO>
    </mainCategories>
    </com.tck.gia.resthome.shared.dto.MenuDTO>

  2. #2
    Join Date
    Nov 2010
    Posts
    174

    Default

    Spring for Android provides support for XML marshaling through the use of the Simple XML Serialization library. You'll need to include the SimpleXmlHttpMessageConverter for this to work. See the reference documentation for more information.
    Roy Clarkson
    Spring Mobile Projects Lead

Posting Permissions

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