title: WCF-client with login-password authentication
body: <p>I'm trying to connect to off-site asmx-service. I have asmx url and login-password for authentication. I've add Service Reference to the service and VS 2010 generated WCF-client with config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;basicHttpBinding&gt;
              &lt;binding name="serviceSoap" /&gt;
          &lt;/basicHttpBinding&gt;
          &lt;customBinding&gt;
              &lt;binding name="serviceSoap12"&gt;
                  &lt;textMessageEncoding messageVersion="Soap12" /&gt;
                  &lt;httpTransport /&gt;
              &lt;/binding&gt;
          &lt;/customBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="http://tourml.danko.ru:9191/Service.asmx"
              binding="basicHttpBinding" bindingConfiguration="serviceSoap"
              contract="DankoTourMLService.serviceSoap" name="serviceSoap" /&gt;
          &lt;endpoint address="http://tourml.danko.ru:9191/Service.asmx"
              binding="customBinding" bindingConfiguration="serviceSoap12"
              contract="DankoTourMLService.serviceSoap" name="serviceSoap12" /&gt;
      &lt;/client&gt;
  </code></pre>
  
  <p></p>
  
  <p>I've created client with basicHttpBinding and set credentials. Then I'm trying to call service method:</p>
  
  <pre><code>var service = new serviceSoapClient("serviceSoap");
  
  service.ClientCredentials.UserName.UserName = username;
  service.ClientCredentials.UserName.Password = password;            
  
  var items = service.GetItemList();
  </code></pre>
  
  <p>But here System.ServiceModel.Security.MessageSecurityException is thrown:</p>
  
  <pre><code>The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''.
  </code></pre>
  
  <p>with inner System.Net.WebException:</p>
  
  <pre><code>{"The remote server returned an error: (401) Unauthorized."}
  </code></pre>
  
  <p>What's wrong with ClientCredentials setting? Should I use another binding, not basicHttpBinding?</p>