title: HTTP GET request with proper content-type is not hitting the expected service method
body: <p>I have 2 restful service method getCustomerJson and getCustomerXML in a class CustomerResource where i am using jersey API for Restful Webservices. All the parameters of the 2 methods are same except one produces xml and other produces json.</p>
  
  <p>When i am using the a HTTP GET request with header Content-Type="application/json" it always invokes the getCustomerXML method which returns xml.</p>
  
  <p>Can someone explain me how jersey works in this kind of situation ?</p>
  
  <pre><code>import java.net.URI;
  import java.util.List;
  import java.util.Map;
  import java.util.concurrent.ConcurrentHashMap;
  import java.util.concurrent.atomic.AtomicInteger;
  
  import javax.ws.rs.Consumes;
  import javax.ws.rs.DELETE;
  import javax.ws.rs.GET;
  import javax.ws.rs.POST;
  import javax.ws.rs.PUT;
  import javax.ws.rs.Path;
  import javax.ws.rs.PathParam;
  import javax.ws.rs.Produces;
  import javax.ws.rs.WebApplicationException;
  import javax.ws.rs.core.Context;
  import javax.ws.rs.core.HttpHeaders;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  
  import domain.Customer;
  
  @Path("/customers")
  public class CustomerResource {
      private static Map&lt;Integer, Customer&gt; customerDB = new ConcurrentHashMap&lt;Integer, Customer&gt;();
      private static AtomicInteger idCounter = new AtomicInteger();
  
      // Constructor
      public CustomerResource() {
      }
  
      @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String sayHello() {
          return "Hello Kundan !!!";
      }
  
  
  
      @GET
      @Path("{id}")
      @Produces("application/xml")
      public Customer getCustomerXML(@PathParam("id") int id, @Context HttpHeaders header) {
          final Customer customer = customerDB.get(id);
          List&lt;String&gt; contentList = header.getRequestHeader("Content-Type");
          List&lt;String&gt; languageList = header.getRequestHeader("Accept-Language");
          List&lt;String&gt; compressionFormatList = header.getRequestHeader("Content-Type");
          if (customer == null) {
              throw new WebApplicationException(Response.Status.NOT_FOUND);
          }
          return customer;
      }
  
      @GET
      @Path("{id}")
      @Produces("application/json")
      public Customer getCustomerJson(@PathParam("id") int id) {
          final Customer customer = customerDB.get(id);
          if (customer == null) {
              throw new WebApplicationException(Response.Status.NOT_FOUND);
          }
          return customer;
      }
  
      @POST
      @Consumes("application/xml")
      public Response createCustomer(Customer customer) {
          customer.setId(idCounter.incrementAndGet());
          customerDB.put(customer.getId(), customer);
          System.out.println("Created customer " + customer.getId());
          return Response.created(URI.create("/customers/" + customer.getId())).build();
  
      }
  
      @PUT
      @Path("{id}")
      @Consumes("application/xml")
      public void updateCustomer(@PathParam("id") int id, Customer customer) {
          Customer current = customerDB.get(id);
          if (current == null)
              throw new WebApplicationException(Response.Status.NOT_FOUND);
  
          current.setFirstName(customer.getFirstName());
          current.setLastName(customer.getLastName());
          current.setStreet(customer.getStreet());
          current.setCity(customer.getCity());
          current.setState(customer.getState());
          current.setZip(customer.getZip());
          current.setCountry(customer.getCountry());
  
      }
  
      @DELETE
      @Path("{id}")
      public void deleteCustomer(@PathParam("id") int id) {
          customerDB.remove(id);
          System.out.println("Deleted !");
  
      }
  }
  </code></pre>