2011-07-26 56 views
3

即使匿名访问的WCF服务的虚拟目录启用和集成身份验证被禁用,我仍然得到错误:使用匿名身份验证调用HTTPS WCF服务?

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.

这是客户端绑定配置的安全定义是什么样子:

<security mode="Transport"> 
    <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
    <message clientCredentialType="None" negotiateServiceCredential="false" /> 
</security> 

和端点定义:

<endpoint address="https://url.com/Service.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" 
      contract="IService" name="WSHttpBinding_IService"> 
      <identity> 
       <servicePrincipalName value="spn" /> 
      </identity> 
</endpoint> 

我已经尝试添加:

client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; 

但它似乎没有任何效果。

IIS上有什么需要改变的东西吗?

[编辑]

服务配置:

<behaviors> 
    <endpointBehaviors> 
     <behavior name="defaultBehavior"/> 
    </endpointBehaviors> 
    <serviceBehaviors> 
     <behavior name="metadataSupport"> 
     <serviceMetadata httpsGetEnabled="true" httpsGetUrl=""/> 
     <useRequestHeadersForMetadataAddress> 
      <defaultPorts> 
       <add scheme="https" port="443" /> 
      </defaultPorts> 
     </useRequestHeadersForMetadataAddress> 
     </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="ServiceLibrary.Service" 
      behaviorConfiguration="metadataSupport"> 
     <endpoint address="" 
       binding="wsHttpBinding" 
       bindingConfiguration="wsSecureBinding" 
       contract="ServiceLibrary.IService"/> 
     <endpoint address="mex" 
       binding="wsHttpBinding" 
       bindingConfiguration="wsSecureBinding" 
       name="mexHttps" 
       contract="IMetadataExchange" /> 
    </service> 
</services> 
<bindings> 
    <wsHttpBinding> 
     <binding name="wsSecureBinding"> 
     <security mode="Transport"/> 
     </binding> 
    </wsHttpBinding> 
</bindings> 
+0

你在服务端使用什么绑定配置? –

+0

我已经添加了服务配置 – ilitirit

回答

6

修改你的绑定配置的服务:

<bindings> 
    <wsHttpBinding> 
     <binding name="wsSecureBinding"> 
      <security mode="Transport"> 
       <transport clientCredentialType="None" /> 
      </security> 
     </binding> 
    </wsHttpBinding> 
</bindings> 

它在默认情况下预计Windows凭据。