title: Sending Objects from Spring MVC 3 REST client to REST provider
body: <p>My intention is to create a Spring 3 MVC web client and Spring MVC REST provider as well.</p>
  
  <p>Here is the code for my REST provider:</p>
  
  <pre><code>@RequestMapping("employee")
  public class EmployeeController {
      @Autowired 
      EmployeeDAO empDao;
  
      @RequestMapping(value = "authenticateUser", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
      public String authenticateUser(HttpServletRequest request, @RequestParam Employee employee) {
          String username = employee.getEmpCode();
          String password = employee.getPassword();
  
          String notExisting = "notExisting";
          String successLogin = "successLogin";
          String wrongPassword = "wrongPassword";
  
          Employee retrievedEmployee = empDao.getById(username);
          if(retrievedEmployee == null) {
              return notExisting;
          } else {
              if(retrievedEmployee.getPassword().equals(password)) {
                  return successLogin;
              } else {
                  return wrongPassword;
              }
          }
      }
  }
  </code></pre>
  
  <p>and here the code for my web client:</p>
  
  <pre><code>@Controller
  public class UserAuthenticationController {
      private final static String SERVICEURL = "http://localhost:8080/cimweb";
  
      /**
       * Simply selects the home view to render by returning its name.
       */
      @RequestMapping(value = "/userAuthentication", method = RequestMethod.POST)
      public @ResponseBody String userAuthentication(Locale locale, Model model, HttpServletRequest request) {
          Employee employee = new Employee();
          String username = request.getParameter("username");
          String password = request.getParameter("password");
  
          employee.setEmpCode(username);
          employee.setPassword(password);
  
          // Prepare acceptable media type
          List&lt;MediaType&gt; acceptableMediaTypes = new ArrayList&lt;MediaType&gt;();
          acceptableMediaTypes.add(MediaType.APPLICATION_JSON);
  
          HttpHeaders headers = new HttpHeaders();
          headers.setAccept(acceptableMediaTypes);
          HttpEntity&lt;Employee&gt; entity = new HttpEntity&lt;Employee&gt;(employee, headers);
  
          RestTemplate restTemplate = new RestTemplate();
          String url = SERVICEURL + "/employee/authenticateUser";
          try {
              ResponseEntity&lt;Employee&gt; result = restTemplate.exchange(url, HttpMethod.POST, entity, Employee.class);
          } catch(Exception e) {
              e.printStackTrace();
          }
  
          return "home";
      }
  }
  </code></pre>
  
  <p>I just want to pass the object Employee to the REST provider so that I can process it and return the String from the REST provider back to the client.</p>
  
  <p>Every time I debug this, when I reach the provider I get null.</p>
  
  <p>I know I missed a lot of things and I have read a few but mostly I see are straight forward request from provider and not an object.</p>
  
  <p>Also, is there any required bean that I should place inside my servlet-context.xml?</p>