title: Calling an HTTPS WCF service with Anonymous authentication?
body: <p>Even though anonymous access is enabled on the Virtual Directory of the WCF service and Integrated Authentication is disabled, I still get the error:</p>
  
  <blockquote>
    <p>The HTTP request is unauthorized with client authentication scheme
    'Anonymous'. The authentication header received from the server was
    'Negotiate,NTLM'.</p>
  </blockquote>
  
  <p>This is what the security definition on client binding configuration looks like:</p>
  
  <pre><code>&lt;security mode="Transport"&gt;
      &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt;
      &lt;message clientCredentialType="None" negotiateServiceCredential="false" /&gt;
  &lt;/security&gt;
  </code></pre>
  
  <p>And the endpoint definition:</p>
  
  <pre><code>&lt;endpoint address="https://url.com/Service.svc"
              binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
              contract="IService" name="WSHttpBinding_IService"&gt;
              &lt;identity&gt;
                  &lt;servicePrincipalName value="spn" /&gt;
              &lt;/identity&gt;
  &lt;/endpoint&gt;
  </code></pre>
  
  <p>I've already tried adding:</p>
  
  <pre><code>client.ClientCredentials.Windows.AllowedImpersonationLevel =  System.Security.Principal.TokenImpersonationLevel.Impersonation;
  </code></pre>
  
  <p>But it doesn't seem to have any effect.</p>
  
  <p>Is there something on IIS that I need to change?</p>
  
  <p>[EDIT]  </p>
  
  <p>Service configuration:</p>
  
  <pre><code>&lt;behaviors&gt;
     &lt;endpointBehaviors&gt;
        &lt;behavior name="defaultBehavior"/&gt;
     &lt;/endpointBehaviors&gt;
     &lt;serviceBehaviors&gt;
        &lt;behavior name="metadataSupport"&gt;
           &lt;serviceMetadata httpsGetEnabled="true" httpsGetUrl=""/&gt;
           &lt;useRequestHeadersForMetadataAddress&gt;
              &lt;defaultPorts&gt;
                 &lt;add scheme="https" port="443" /&gt;
              &lt;/defaultPorts&gt;
           &lt;/useRequestHeadersForMetadataAddress&gt;
        &lt;/behavior&gt;
     &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;services&gt;
     &lt;service name="ServiceLibrary.Service"
              behaviorConfiguration="metadataSupport"&gt;
        &lt;endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="wsSecureBinding"
                  contract="ServiceLibrary.IService"/&gt;
        &lt;endpoint address="mex"
                  binding="wsHttpBinding"
                  bindingConfiguration="wsSecureBinding"
                  name="mexHttps"
                  contract="IMetadataExchange" /&gt;
     &lt;/service&gt;
  &lt;/services&gt;
  &lt;bindings&gt;
     &lt;wsHttpBinding&gt;
        &lt;binding name="wsSecureBinding"&gt;
           &lt;security mode="Transport"/&gt;
        &lt;/binding&gt;
     &lt;/wsHttpBinding&gt;
  &lt;/bindings&gt;
  </code></pre>