2013-08-23 56 views
2

我已更改Web.Config并且该服务正在使用匿名身份验证。尽管启用了Windows身份验证并且IIS7.5中禁用了匿名身份验证,但它开始给我提供以下错误。请帮忙。WCF服务Windows身份验证不起作用

主机 (“IntegratedWindowsAuthentication”)上配置的认证方案不允许 结合“basicHTTP”(“匿名”)的那些配置。请确保将 SecurityMode设置为Transport或TransportCredentialOnly。 此外,这可以通过改变认证 方案为通过IIS管理工具本申请中,通过 的ServiceHost.Authentication.AuthenticationSchemes属性,则 应用配置文件中的 元件,通过在更新ClientCredentialType属性来解决绑定, 或通过调整 HttpTransportBindingElement上的AuthenticationScheme属性。

Web.config文件如下:提前

<?xml version="1.0"?> 
<configuration> 

<appSettings> 
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
<system.web> 
<compilation debug="true" targetFramework="4.5" /> 
<httpRuntime targetFramework="4.5"/> 
</system.web> 
<system.serviceModel> 
<bindings> 
    <webHttpBinding> 
    <binding name="JSONBinding"></binding> 
    </webHttpBinding> 
    <basicHttpBinding> 
    <binding name="basicHTTP"> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows"></transport> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="basicBehavior"> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>  
     <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <behavior name="JSON"> 
     <webHttp/> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<services> 
<service name="RestWCFService.CalculationService" behaviorConfiguration="basicBehavior"> 
<endpoint address="" binding="basicHttpBinding" contract="RestWCFService.ICalculatorService" bindingName ="basicHTTP"></endpoint> 
    <!--  
    <endpoint behaviorConfiguration="JSON" binding="webHttpBinding" bindingConfiguration="JSONBinding" contract="RestWCFService.ICalculatorService" name="JSONService"></endpoint> 
    --> 
    </service>  
</services> 

<protocolMapping> 
    <add binding="basicHttpBinding" scheme="http"/> 
    <add binding="basicHttpsBinding" scheme="https" /> 
</protocolMapping>  
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
<modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
    To browse web app root directory during debugging, set the value below to true. 
    Set to false before deployment to avoid disclosing web app folder information. 
    --> 
    <directoryBrowse enabled="true"/> 
</system.webServer> 

</configuration> 

谢谢!

回答

2

您没有在端点中使用名为basicHTTP的基本HTTP绑定。将端点中的属性从bindingName="basicHTTP"更改为bindingConfiguration="basicHTTP"

顺便说一下,您可能需要在IIS中启用匿名身份验证和Windows身份验证。

+0

感谢您使用bindingConfiguration指出内容。更改它会导致另一个Windows身份验证错误。虽然在Windows身份验证中,我们不需要禁用匿名?错误是:在IIS上配置的扩展保护设置与传输上配置的设置不匹配。 ExtendedProtectionPolicy.PolicyEnforcement值不匹配。 IIS的值为Always,而WCF传输的值为Never。 –

+0

我从来没有这样的错误。无法帮助你。 – Yavuz

+0

基本上,由于IIS7.5 Windows身份验证和扩展保护设置为必需/始终与我一起发生错误。无论如何谢谢让我摆脱以前的错误。谢谢。 –