title: Setting up authentication for SSL protected WSIT / Metro web service and client
body: <p>I'm kind of confused about setting up standard authentication for my SSL protected service. I have tried the <a href="http://www.mkyong.com/webservices/jax-ws/application-authentication-with-jax-ws/" rel="nofollow">HTTP header way</a>, but that's non standard, and WS-I is important for me. It is possible to set up the <code>Authentication Token</code> to be <code>Username</code> on method level. This is the resulted <code>BindingPolicy</code> in the WSIT XML:</p>
  
  <pre><code>&lt;wsp:Policy wsu:Id="DataStoreWSPortBindingPolicy"&gt;
      &lt;wsp:ExactlyOne&gt;
          &lt;wsp:All&gt;
              &lt;wsam:Addressing wsp:Optional="false"/&gt;
              &lt;sp:TransportBinding&gt;
                  &lt;wsp:Policy&gt;
                      &lt;sp:TransportToken&gt;
                          &lt;wsp:Policy&gt;
                              &lt;sp:HttpsToken RequireClientCertificate="false"/&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/sp:TransportToken&gt;
                      &lt;sp:Layout&gt;
                          &lt;wsp:Policy&gt;
                              &lt;sp:Lax/&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/sp:Layout&gt;
                      &lt;sp:IncludeTimestamp/&gt;
                      &lt;sp:AlgorithmSuite&gt;
                          &lt;wsp:Policy&gt;
                              &lt;sp:Basic128/&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/sp:AlgorithmSuite&gt;
                  &lt;/wsp:Policy&gt;
              &lt;/sp:TransportBinding&gt;
              &lt;sp:Wss10/&gt;
          &lt;/wsp:All&gt;
      &lt;/wsp:ExactlyOne&gt;
  &lt;/wsp:Policy&gt;
  &lt;wsp:Policy wsu:Id="DataStoreWSPortBinding_hello_Input_Policy"&gt;
      &lt;wsp:ExactlyOne&gt;
          &lt;wsp:All&gt;
              &lt;sp:SupportingTokens&gt;
                  &lt;wsp:Policy&gt;
                      &lt;sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt;
                          &lt;wsp:Policy&gt;
                              &lt;sp:WssUsernameToken10/&gt;
                          &lt;/wsp:Policy&gt;
                      &lt;/sp:UsernameToken&gt;
                  &lt;/wsp:Policy&gt;
              &lt;/sp:SupportingTokens&gt;
          &lt;/wsp:All&gt;
      &lt;/wsp:ExactlyOne&gt;
  &lt;/wsp:Policy&gt;
  </code></pre>
  
  <p><strong>SvcUtil warnings:</strong></p>
  
  <pre><code>&lt;!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'http://webServices/':    --&gt;
            &lt;!--    &lt;wsdl:binding name='DataStoreWSPortBinding'&gt;    --&gt;
            &lt;!--        &lt;sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"&gt;..&lt;/sp:SupportingTokens&gt;    --&gt;
  </code></pre>
  
  <p>I want to set credentials in the WCF client via <code>ClientCredentials</code> and then authenticate on the service side via database. What are the steps to achieve that?</p>