c# - 通过禁用匿名身份验证出现 WCF REST 服务问题
问题描述
主机上配置的身份验证方案('IntegratedWindowsAuthentication')不允许在绑定'BasicHttpBinding'('Anonymous')上配置的那些。请确保将 SecurityMode 设置为 Transport 或 TransportCredentialOnly。此外,可以通过 IIS 管理工具、通过 ServiceHost.Authentication.AuthenticationSchemes 属性、在元素的应用程序配置文件中更改此应用程序的身份验证方案、通过更新绑定上的 ClientCredentialType 属性或通过调整来解决此问题HttpTransportBindingElement 上的 AuthenticationScheme 属性。
我们有一个托管在 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>
请问有什么建议或线索,你认为可以解决这个问题吗?
提前致谢。
拉杰库马尔。
解决方案
我在我的应用程序中遇到了类似的问题。
我对该服务的行为配置和名称有疑问。我有正确的如下。这解决了我的问题。
例子:
<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 文件。
推荐阅读
- javascript - 尝试设置变量时返回未定义的函数
- angular - 启用 Ivy 的 Angular 8 - @swimlane/ngx-datatable 抛出入口点错误
- python - ImportError:无法导入名称“RGBColor”
- oracle - Oracle 查询 [需要子查询?]
- php - 加载 xdebug.so 未定义符号失败:zend_empty_string
- javascript - React 中的 ChartJS - 即使触发了渲染方法,更改数据集道具也不会更改视图
- haskell - 如何对包装在 IO monad 中的值使用数据构造函数?
- android - 由于 Internet 许可,CTS 失败
- reactjs - 如何更改反应组件中的颜色
- python - PyQt5 专注于只读 QLineEdit 小部件