title: Connect with WCF to a WebService authenticated with username/password
body: <p>I created a proxy of a Web Service with Visual Studio 2008, and it created for me the following entry in the app.config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="MyNameHandlerSoapBinding" closeTimeout="00:01:00"
                      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                      useDefaultWebProxy="true"&gt;
                      &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                          maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                      &lt;security mode="None"&gt;
                          &lt;transport clientCredentialType="None" proxyCredentialType="None"
                              realm="" /&gt;
                          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/basicHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
            &lt;endpoint address="http://www.***/***/***"
                binding="basicHttpBinding" bindingConfiguration="MyNameHandlerSoapBinding"
                contract="***.MyNameHandler" name="MyName"&gt;
            &lt;/endpoint&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>The webservice is has username/password authentication so I need to add it somewhere here. </p>
  
  <p>I'm a bit lost in the sea of WCF documentation, I think I have to change from basicHttpBinding to wsHttpBinding or customBinding to be able to add the authentication elements, but I don't really understand it. Could anybody give any quick tip or any useful link that says how to do so?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I changed the security section to:</p>
  
  <pre><code>&lt;security mode="Transport"&gt;
      &lt;transport clientCredentialType="Basic" proxyCredentialType="None"
           realm="" /&gt;
  &lt;/security&gt;
  </code></pre>
  
  <p>and added in the code:</p>
  
  <pre><code>ws.ClientCredentials.UserName.UserName = "";
  ws.ClientCredentials.UserName.Password = "";
  </code></pre>
  
  <p>Now it seems it might be using the credentials but it's giving me the error:</p>
  
  <p><em>the provided URI scheme 'http' is invalid URI expected 'https'</em></p>
  
  <p>I don't even know if this is the right way to go...</p>