title: JAX-WS and BASIC authentication, when user names and passwords are in a database
body: <p>I'm new to JAX-WS and there's a thing which I don't understand.</p>
  
  <p>There's a ton of tutorials available on how to set up JAX-WS security, but in pretty much all cases BindingProvider.USERNAME_PROPERTY and BindingProvider.PASSWORD_PROPERTY are stored in some .xml file(depending on the container I believe) - they are "hardcoded" that is. And that's what I don't get. How can I authenticate a web service client by comparing BindingProvider.USERNAME_PROPERTY and BindingProvider.PASSWORD_PROPERTY with a user name and password that's in a database? I tried setting BindingProvider.USERNAME_PROPERTY and BindingProvider.PASSWORD_PROPERTY on the client side like this:</p>
  
  <pre><code>    ShopingCartService scs = new ShopingCartService(wsdlURL, name);
      ShopingCart sc = scs.getShopingCartPort();
      Map&lt;String, Object&gt; requestContext = ((BindingProvider)sc).getRequestContext();
      requestContext.put(BindingProvider.USERNAME_PROPERTY, userName);
      requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
      sc.someFunctionCall();
  </code></pre>
  
  <p>And then, on the server side retrieving like this:</p>
  
  <pre><code>@Resource
  WebServiceContext wsContext;
  
  @WebMethod
  public void someFunctionCall() {
      MessageContext mc = wsContext.getMessageContext();
      mc.get(BindingProvider.USERNAME_PROPERTY);
      mc.get(BindingProvider.PASSWORD_PROPERTY);
  }
  </code></pre>
  
  <p>But I always get null, I didn't set up anything in xml, web service works just fine, except I can't get those variables :(</p>
  
  <p>I'm running both on java 1.6, tomcat 6 and <a href="https://jax-ws.dev.java.net/" rel="noreferrer">JAX-WS</a>.</p>
  
  <p>Any help with authenticating users with passwords from a database is greatly appreciated,
  Thanks.</p>