wcf - 无法在本地计算机上运行 WCF 服务

标签 wcf .net-4.0

我有一个 wcf 服务,只有在我将它部署到服务器并通过 IIS 配置后才能工作。通过 IIS express 运行它时出现的错误消息是:

The authentication schemes configured on the host ('Ntlm, Anonymous') do not allow those configured on the binding 'BasicHttpBinding' ('Negotiate'). Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly. Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.



我的 web.config 服务 binging 如下所示:
 <services>
      <service name="LMS.Services.Services.AppService" behaviorConfiguration="LargeDataRequestBehavior">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp_LargeDataRequestBinding" contract="LMS.Services.Services.AppService" />
        <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="basicHttp_LargeDataRequestBinding" contract="IMetadataExchange" />
      </service> </services>

我的绑定(bind)看起来像这样:
   <bindings>
      <basicHttpBinding>
        <binding name="basicHttp_LargeDataRequestBinding" receiveTimeout="01:00:00" sendTimeout="01:00:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />          
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" >              
            </transport>
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      <basicHttpBinding>
    </bindings>

任何帮助将不胜感激。

最佳答案

尝试改变这部分。问题是凭据类型 Windows 的枚举映射到称为协商​​的协议(protocol)。 IIS 通知您尚未在您的网站上启用协商,仅允许 Basic(无安全性)和 Ntlm(另一种形式的 Windows 安全性)。

<bindings>
  <basicHttpBinding>   
    <binding>      
      <security >
        <transport clientCredentialType="Ntlm" >              
        </transport>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

这里的 WTF 是“协商”和“Windows”之间存在不匹配。

关于wcf - 无法在本地计算机上运行 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18450017/

相关文章:

c# - 使用 Entity Framework 和 WCF 的大型应用程序

c# - 如何在添加到字典之前检查键是否存在

c# - 使用没有导航 View 的 MVVM 模式的 WPF 切换 View

c# - 序列化 TypeBuilder 列表

c# - ConcurrentDictionary.GetOrAdd 始终执行委托(delegate)方法

.net - 即时修改 app.config

c# - WCF 以 JSON 格式返回 double 并在昏迷后限制数字

wcf - JSONP 对您的 API 来说是必须的吗?

C# Wcf 连接导致 TCP/IP 端口耗尽

c# - 是否可以创建具有两个同名属性的类型?