title: Read http post headers
body: <p>Hi I am having trouble I am trying to learn restful services.I created a web service using jax-rs which is shown below</p>
  
  <pre><code>@Path("/users")
  public class Welcome {
  @POST
  @Consumes("text/xml")
  @Produces("text/xml") 
  public Response welcome(String incomingXML){
  return Response.status(200).entity("timestamp : " + incomingXML).build();
  }
  }
  </code></pre>
  
  <p>I use the following test client to test the service </p>
  
  <pre><code>public class TestService {
  public static void main(String args[]) throws ParserConfigurationException, SAXException, IOException {
  ClientConfig config = new DefaultClientConfig();
  Client client=Client.create(config);
  WebResource service=client.resource(getBaseURI());
  String urlString = "http://localhost:8080/JaXRSDemo/rest/users";
  URL url = new URL( urlString );
  HttpURLConnection con = (HttpURLConnection) url.openConnection();
  
  // set up url connection to get retrieve information back
  con.setRequestMethod( "POST" );
  con.setDoInput( true );
  
  // stuff the Authorization request header
  byte[] encodedPassword = ( userName + ":" + password ).getBytes();
  
  con.setRequestProperty( "Authorization",encodedPassword.toString() );
  Customer customer=new Customer();
  customer.setName("noobstre");
  customer.setPin(123455);
  
  ClientResponse response=service.path("rest").path("users").type(MediaType.APPLICATION_XML).post(ClientResponse.class,customer);
  System.out.println(" response " + response.getEntity(String.class));
  }
  private static URI getBaseURI() {
  return UriBuilder.fromUri("http://localhost:8080/JaXRSDemo").build();
  }
  }
  </code></pre>
  
  <p>I want to use the password in the header at the server side and do a lookup with the database.The problem I am facing is how do I   read the headers at the server.</p>