WCF身份验证绑定错误

WCF身份验证绑定错误,wcf,web-services,iis,wcf-binding,Wcf,Web Services,Iis,Wcf Binding,我有一个WCF服务,它也使用sharepoint userprofile服务。 当我尝试在IIS上运行服务时,出现此错误 在主机上配置的身份验证方案 ('IntegratedWindowsAuthentication')不允许在上配置的 绑定“WSHttpBinding”(“匿名”)。请确保 SecurityMode设置为Transport或TransportCredentialOnly。 此外,这可以通过更改身份验证来解决 通过IIS管理工具,通过 中的ServiceHost.Authenti

我有一个WCF服务,它也使用sharepoint userprofile服务。 当我尝试在IIS上运行服务时,出现此错误

在主机上配置的身份验证方案 ('IntegratedWindowsAuthentication')不允许在上配置的 绑定“WSHttpBinding”(“匿名”)。请确保 SecurityMode设置为Transport或TransportCredentialOnly。 此外,这可以通过更改身份验证来解决 通过IIS管理工具,通过 中的ServiceHost.Authentication.AuthenticationSchemes属性 应用程序配置文件位于 元素,通过更新绑定上的ClientCredentialType属性, 或者通过调整 HttpTransportBindingElement

这是我的web.config

<bindings>
<basicHttpBinding>

    <binding name="UserProfileServiceSoap" 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">
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="TransportCredentialOnly">
    <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
    </binding>

</basicHttpBinding>
<wsHttpBinding>

    <binding name="HttpBinding1" maxReceivedMessageSize="2147483647" receiveTimeout="10:00:00" openTimeout="10:00:00"
    sendTimeout="10:00:00" closeTimeout="10:00:00" bypassProxyOnLocal="false" transactionFlow="false"
    hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288000" allowCookies="false">
    <security mode="None"/>
    </binding>

    <binding name="WSHttpBinding_MessageSecurity" maxReceivedMessageSize="2147483647" receiveTimeout="10:00:00"
    openTimeout="10:00:00" sendTimeout="10:00:00" closeTimeout="10:00:00" bypassProxyOnLocal="false"
    transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288000" allowCookies="false">
    <security mode="Message">
    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
    <extendedProtectionPolicy policyEnforcement="Never"/>
    </transport>
    <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
    </security>
    </binding>

</wsHttpBinding>
</bindings>

services>
<service name="UserProfileWcf.UserProfileService" behaviorConfiguration="UserProfileWcf.UserProfileServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpBinding1" contract="UserProfileWcf.ServiceContract.IUserProfileService" name="UserProfileServiceEndpoint">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="UserProfileWcf.UserProfileServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="65536000"/>
<serviceThrottling maxConcurrentSessions="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
        <client>
            <endpoint address="http://xyz/_vti_bin/userprofileservice.asmx"
                    binding="basicHttpBinding" bindingConfiguration="UserProfileServiceSoap"
                    contract="SharePointUserProfileService.UserProfileServiceSoap"
                    name="UserProfileServiceSoap" />
        </client>

服务>

同样的配置在我的本地机器上运行良好。我的绑定哪里出了问题?

我认为您使用wsHttpBinding为一个端点定义一个绑定的配置是HttpBinding1,它的安全模式设置为“无”。当您在IIS中托管服务(因此IIS充当服务主机)时,您似乎使用了Windows身份验证。尝试将HttpBinding1的安全模式设置为Transport,或者尝试将IIS身份验证更改为anonymous,以查看其是否有效。

我认为,您使用wsHttpBinding为其中一个端点定义安全模式的配置是HttpBinding1,它的安全模式设置为none。当您在IIS中托管服务(因此IIS充当服务主机)时,您似乎使用了Windows身份验证。尝试将HttpBinding1的安全模式设置为Transport,或者尝试将IIS身份验证更改为anonymous,以查看其是否有效。当您说相同的配置在您的计算机上可以正常工作时,您是指开发环境吗?哦,工作正常(允许匿名)。\我很惊讶。我怎么会错过这么一件小但重要的事情。谢谢Vibhu,请将您的答案单独发布,这样我可以将其标记为答案