WCF身份验证绑定错误

时间:2013-07-11 16:53:23

标签: wcf web-services iis wcf-binding

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

  

主机上配置的身份验证方案   ('IntegratedWindowsAuthentication')不允许配置的那些   绑定'WSHttpBinding'('匿名')。请确保   SecurityMode设置为Transport或TransportCredentialOnly。   此外,这可以通过更改身份验证来解决   通过IIS管理工具,通过这个应用程序的方案   ServiceHost.Authentication.AuthenticationSchemes属性,在   应用程序配置文件在   element,通过更新绑定上的ClientCredentialType属性,   或者通过调整AuthenticationScheme属性   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>

相同的配置在我的本地计算机上正常工作。我的绑定在哪里出错?

1 个答案:

答案 0 :(得分:1)

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