title: RestTemplate.getObjectFor(String url, Class<T> responseType) and RestTemplate.getObjectFor(URI url, Class<T> responseType)
body: <p>I have problem with Spring RestTemplate, i try to get data from an address which return JSON. When i use RestTemplate.getObjectFor(String url, Class responseType) i got Exception about Could not read document: Unexpected character ('&lt;' (code 60)). But if i use RestTemplate.getObjectFor(URI url, Class responseType) then it works!</p>
  
  <p>Can anyone tell me why that happen?</p>
  
  <p>Here is the configuration for rest template,</p>
  
  <pre><code> @Bean(name = "cernerRestTemplate")
    public RestTemplate cernerRestTemplate() throws NoSuchAlgorithmException {
      RestTemplate cernerRestTemplate = new RestTemplate();
      cernerRestTemplate.setRequestFactory(getHttpComponentsClientHttpRequestFactory());
      cernerRestTemplate.setMessageConverters(getMessageConverters());
      cernerRestTemplate.setInterceptors(getInterceptors());
      return cernerRestTemplate
  }
  
  private List&lt;ClientHttpRequestInterceptor&gt; getInterceptors() {
    Map&lt;String, String&gt; requestHeaders = new HashMap&lt;String, String&gt;();
    requestHeaders.put(HttpHeaders.ACCEPT, "*");
  
    Map&lt;String, String&gt; responseHeaders = new HashMap&lt;String, String&gt;();
    responseHeaders.put(HttpHeaders.CONTENT_TYPE,      MediaType.APPLICATION_XML_VALUE);
  
    HeaderHttpRequestInterceptor headerHttpRequestInterceptor = new HeaderHttpRequestInterceptor();
    headerHttpRequestInterceptor.setRequestHeaders(requestHeaders);
    headerHttpRequestInterceptor.setResponseHeaders(responseHeaders);
  
    BasicAuthenticationRequestInterceptor basicAuthenticationRequestInterceptor =
      new BasicAuthenticationRequestInterceptor(username, password);
  
    List&lt;ClientHttpRequestInterceptor&gt; interceptors = new ArrayList&lt;ClientHttpRequestInterceptor&gt;();
    interceptors.add(basicAuthenticationRequestInterceptor);
    interceptors.add(headerHttpRequestInterceptor);
  
    return interceptors;
  }
  
  private List&lt;HttpMessageConverter&lt;?&gt;&gt; getMessageConverters() {
    List&lt;MediaType&gt; supportedMediaTypes = new ArrayList&lt;MediaType&gt;();
    supportedMediaTypes.add(MediaType.APPLICATION_XML);
  
    MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter =
      new MappingJackson2HttpMessageConverter();
     mappingJackson2HttpMessageConverter.setSupportedMediaTypes(supportedMediaTypes);
  
    List&lt;HttpMessageConverter&lt;?&gt;&gt; messageConverters = new ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt;();
    messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
    messageConverters.add(mappingJackson2HttpMessageConverter);
  
    return messageConverters;
  }
  
  private HttpComponentsClientHttpRequestFactory getHttpComponentsClientHttpRequestFactory()
    throws NoSuchAlgorithmException {
    RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
    requestConfigBuilder.setConnectTimeout(connectTimeout);
    requestConfigBuilder.setSocketTimeout(socketTimeout);
    RequestConfig requestConfig = requestConfigBuilder.build();
  
    HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
    httpClientBuilder.setDefaultRequestConfig(requestConfig);
    httpClientBuilder.setMaxConnPerRoute(maxConnPerRoute);
    httpClientBuilder.setMaxConnTotal(maxConnTotal);
    httpClientBuilder.setSSLSocketFactory(new     CustomSslConnectionSocketFactory());
  
    return new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
  }
  </code></pre>