【发布时间】:2016-12-24 18:45:31
【问题描述】:
编写了一个从 BasicHttpBinding 开始的 web 服务,用于简单的服务开发,而不必担心安全性。在将它移动到 Web 服务器时,我将绑定切换到 WsHttpBinding 以及基本身份验证,就像 Web 服务器上的另一个 Web 服务一样。但是,当我浏览到 Web 服务以验证它是否正在运行时,它表示配置的绑定仍然是 BasicHttpBinding。已验证 IIS 指向正确的位置。
在主机('Basic')上配置的身份验证方案不允许在绑定'BasicHttpBinding'('Anonymous')上配置的那些。请确保将 SecurityMode 设置为 Transport 或 TransportCredentialOnly。此外,可以通过 IIS 管理 > 工具,通过 ServiceHost.Authentication.AuthenticationSchemes >property,在应用程序配置文件中的 > 元素中,通过更新绑定上的 ClientCredentialType 属性来解决此问题,或通过调整 HttpTransportBindingElement 上的 AuthenticationScheme 属性。
Web.config
<configuration>
<appSettings>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinder">
<security mode="Transport">
<transport clientCredentialType="Basic"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="MyBinder"
name="MyEndpoint"
contract="MyService.IMyInterface"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
【问题讨论】:
标签: c# asp.net web-services wcf iis