title: Spring Rest Client implementation : Could not extract response: no suitable HttpMessageConverter found for response type with xstreamMarshaller
body: <p>I am developing client server application using spring mvc and rest.
  Its simple calculator service in which client calls the methods from server to execute operations.</p>
  
  <p><strong>This is my rest client code restClient.java:</strong> </p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package com.blog.samples.client;
  
  /**
   *
   * @author bhushan.baviskar
   */
  import com.blog.samples.domain.Calculator;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  import org.springframework.web.client.RestTemplate;
  
  public class restClient {
  
    public static void main(String [] args)
    {
        restClient tmp = new restClient();
        tmp.calltoserver();
    }
    public void calltoserver() {
      ApplicationContext applicationContext = new ClassPathXmlApplicationContext("../../../../appContext.xml", restClient.class);
      RestTemplate restTemplate = applicationContext.getBean("restTemplate", RestTemplate.class);
      String url = "http://localhost:8080/rest/calc/4&amp;3&amp;+";
      Calculator calObj = (Calculator) restTemplate.getForObject(url, Calculator.class);
      System.out.println("details " + calObj.getDetails());
      System.out.println("done");
    }
  }
  </code></pre>
  
  <p><strong>And this is my appContext.xml file :</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
                             http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
    &lt;bean id="restTemplate" class="org.springframework.web.client.RestTemplate"&gt;
          &lt;property name="messageConverters"&gt;
        &lt;bean id="messageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"&gt;
          &lt;property name="marshaller" ref="xstreamMarshaller" /&gt;
          &lt;property name="unmarshaller" ref="xstreamMarshaller" /&gt;
        &lt;/bean&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  
    &lt;bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"&gt;
      &lt;property name="aliases"&gt;
      &lt;props&gt;
        &lt;prop key="Calculator"&gt;com.blog.samples.webservices.rest.CalcController&lt;/prop&gt;
      &lt;/props&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>I am getting response in json format but when I execute the restclient.java file it says :</strong> </p>
  
  <pre><code>DEBUG: [Dec-11 16:54:39,706] web.client.RestTemplate - GET request for "http://localhost:8080/rest/calc/4&amp;3&amp;+" resulted in 200 (OK)
  
  Exception in thread "main" org.springframework.web.client.RestClientException: **Could not extract response: no suitable HttpMessageConverter found for response type** [com.blog.samples.domain.Calculator] and content type [text/plain;charset=UTF-8]
      at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:84)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
      at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:199)
      at com.blog.samples.client.restClient.calltoserver(restClient.java:27)
      at com.blog.samples.client.restClient.main(restClient.java:21)
  ------------------------------------------------------------------------
  </code></pre>
  
  <p>I am new to the Spring Rest client Development so any help will be appreciated.</p>
  
  <p>If anyone knows pl. tell me How to handle the response?</p>