【问题标题】:Issue with WCF REST Service by disabling Anonymous Authentication通过禁用匿名身份验证出现 WCF REST 服务问题
【发布时间】:2019-10-31 02:13:15
【问题描述】:

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

我们有一个托管在 IIS 7.5 上的 WCF Rest 服务 如果启用匿名身份验证(在 IIS 中),我们就可以浏览服务。

但是如果禁用 IIS 上的匿名身份验证,则会出现上述错误消息。

我们正在使用 webHttpBinding 并使用以下定义进行绑定

<binding name="ExternalServicesRestBinding" closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
          </security>
        </binding>

端点行为为

 <behavior name="endpointBehaviourForRestService">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <webHttp />
        </behavior>

请提供任何建议或线索,您认为可以解决问题吗?

提前致谢。

拉库马尔。

【问题讨论】:

    标签: c# rest wcf iis-7.5


    【解决方案1】:

    我在我的应用程序中遇到了类似的问题。

    我对该服务的 service behaviorConfigurationname 有疑问。我有正确的如下。这解决了我的问题。

    示例:

    <system.serviceModel>
        <services>
          <service behaviorConfiguration="ServiceBehavior" name="service_namespace.service_Class" >
    

    另外一点是,当您正在实施 REST 服务时,我们需要将 Factory="System.ServiceModel.Activation.WebServiceHostFactory" 添加到 .svc 文件中。 (您会收到“未找到端点”错误,但是当您正确调用它时,服务可以正常工作。如前所述,我正在使用带有 .NET 4.6(简化 WCF 配置)的默认 Web.config,所以我可能还没有需要添加端点详细信息才能再次工作)。

    请检查您的配置设置和 svc 文件。

    【讨论】:

    • 感谢 Jagadeesh 的建议。似乎这解决了问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 2011-03-28
    相关资源
    最近更新 更多