title: Authentication on WCF Service using BasicHttpBinding and Authorization header
body: <p>I'm having some issue with authentication on a third party's WCF service. I don't know how it's configured, it's like a black box for me. The only thing that I know, that those webservice should use Basic authentication, but may not.</p>
  
  <p>I've added fiddler, and even wireshark to analyze what's happening inside of those requests, and found out that requests with <code>authorization</code> header do get authenticated. So basically, using a SoapUI I was able to authenticate on those WCF service.</p>
  
  <p>I've generated a test client using <code>svcutil</code> and specified config file like this:</p>
  
  <pre><code> &lt;bindings&gt;
     &lt;basicHttpBinding&gt;
       &lt;binding name="BasicHttpBinding_1" useDefaultWebProxy="false" &gt;
         &lt;security mode="Message" &gt;
           &lt;message clientCredentialType="UserName" /&gt;
         &lt;/security&gt;
       &lt;/binding&gt;        
     &lt;/basicHttpBinding&gt;
   &lt;/bindings&gt;
   &lt;client&gt;
     &lt;endpoint address="http://theurl.svc"
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_1"
       contract="CA_TestMediaSaturn.IDCIntegration" name="BasicHttpBinding_2" /&gt;
   &lt;/client&gt;
  </code></pre>
  
  <p>Also I've added authorization information to client in code file:</p>
  
  <pre><code> client.ClientCredentials.UserName.UserName = "one";
   client.ClientCredentials.UserName.Password = "two";
  </code></pre>
  
  <p>But I wasn't able to get those <code>Authorization</code> header encoded in base64.
   I wonder how can I configure my client to obtain those header in order to get authorized on webservice side. I did found an <a href="http://www.west-wind.com/weblog/posts/2010/Feb/18/NET-WebRequestPreAuthenticate-not-quite-what-it-sounds-like" rel="nofollow">article</a> describing how to make it on your own. But maybe there is a way to make it a lot easier?</p>
  
  <p>UPDATE 1:</p>
  
  <p>I've just receiver service configuration settings from 3rd party vendor. Mb it can somehow help in finding out the reason of error.</p>
  
  <pre><code> &lt;bindings&gt;
   &lt;basicHttpBinding&gt;
   &lt;binding name="BasicHttpBinding_1" &gt;
                   &lt;security mode="TransportCredentialOnly"&gt;
                     &lt;message clientCredentialType="UserName"/&gt;
                   &lt;/security&gt;
                 &lt;/binding&gt;
   &lt;/basicHttpBinding&gt;
   &lt;/bindings&gt;
  </code></pre>