title: The HTTP request is unauthorized with client authentication scheme 'Anonymous'?
body: <p>While trying to invoke a RESTful service(i have used UserNameAuthenticator from this sample for RESTful service <a href="https://stackoverflow.com/questions/4715752/adding-basic-http-auth-to-a-wcf-rest-service">Adding basic HTTP auth to a WCF REST service</a>) from my web client application am getting an error like   </p>
  
  <pre><code>The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic Realm'.
  </code></pre>
  
  <p>Client CS code</p>
  
  <pre><code>BasicHttpBinding binding = new BasicHttpBinding();
  binding.SendTimeout = TimeSpan.FromSeconds(25);
  binding.Security.Transport.ClientCredentialType =
  HttpClientCredentialType.Basic;
  EndpointAddress address = new  EndpointAddress("http://localhost:12229/RestServiceImpl.svc");
  ChannelFactory&lt;RestService.IRestServiceImpl&gt; factory =
  new ChannelFactory&lt;RestService.IRestServiceImpl&gt;(binding, address);
  RestService.IRestServiceImpl channel = factory.CreateChannel();
  channel.GetStudent();
  </code></pre>
  
  <p>Client Web.config</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="RestService.RestServiceImpl"&gt;
          &lt;endpoint address="http://localhost:12229/RestServiceImpl.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ExternalSystemsService_v1Interface"
            contract="RestService.IRestServiceImpl"
            name="ExternalSystemsService_v1Port" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="BasicHttpBinding_ExternalSystemsService_v1Interface"
                           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="TransportCredentialOnly"&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;/system.serviceModel&gt;
  </code></pre>
  
  <p>and RESTful service Web.config</p>
  
  <pre><code> &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="webHttpTransportSecurity"&gt;
            &lt;security mode="TransportCredentialOnly"&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;services&gt;
        &lt;service name="RestService.RestServiceImpl"&gt;
          &lt;endpoint name="ExternalSystemsService_v1Port" address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ExternalSystemsService_v1Interface" contract="RestService.IRestServiceImpl"&gt;&lt;/endpoint&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior&gt;
            &lt;webHttp /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="SecureRESTSvcTestBehavior"&gt;
  &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;serviceCredentials&gt;
              &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="RESTfulSecuritySH.CustomUserNameValidator, RESTfulSecuritySH" /&gt;
            &lt;/serviceCredentials&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Any suggestion?</p>