title: What is the restTemplate.exchange() method for?
body: <p>Actually what does the <code>restTemplate.exchange()</code> method do?</p>
  
  <pre class="lang-java prettyprint-override"><code>@RequestMapping(value = "/getphoto", method = RequestMethod.GET)
  public void getPhoto(@RequestParam("id") Long id, HttpServletResponse response) {
  
      logger.debug("Retrieve photo with id: " + id);
  
      // Prepare acceptable media type
      List&lt;MediaType&gt; acceptableMediaTypes = new ArrayList&lt;MediaType&gt;();
      acceptableMediaTypes.add(MediaType.IMAGE_JPEG);
  
      // Prepare header
      HttpHeaders headers = new HttpHeaders();
      headers.setAccept(acceptableMediaTypes);
      HttpEntity&lt;String&gt; entity = new HttpEntity&lt;String&gt;(headers);
  
      // Send the request as GET
      ResponseEntity&lt;byte[]&gt; result = 
          restTemplate.exchange("http://localhost:7070/spring-rest-provider/krams/person/{id}", 
                                HttpMethod.GET, entity, byte[].class, id);
  
      // Display the image
      Writer.write(response, result.getBody());
  }
  </code></pre>