【发布时间】:2020-11-20 05:32:39
【问题描述】:
我有一个 WCF 端点,它使用 basicHttpBinding 公开 API。此出价设置为使用安全模式TransportWithMessageCredentialand UserName 为clientCredentialType。
由于安全性是在消息级别实现的,因此在 WCF 中,IIS 需要允许匿名访问。因此,无需提供任何凭据即可获取 wsdl。
如何强制认证获取服务元数据?
这里当前的服务配置看起来像(来自 web.config)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="secure">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="secure" name="someProject.MyService">
<endpoint binding="basicHttpBinding" contract="someProject.IService" bindingConfiguration="secure" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="secure">
<serviceMetadata httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我尝试了显而易见的方法,通过使用服务行为配置为元数据设置特定绑定:
<behavior name="secure">
<serviceMetadata httpsGetEnabled="true" httpsGetBinding="basicHttpBinding" httpsGetBindingConfiguration="transportSecure" />
</behavior>
//and add the new binding
<basicHttpBinding>
<binding name="transportSecure">
<security mode="Transport">
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
但不支持。它抛出这个:
MessageVersion 'Soap11 (http://schemas.xmlsoap.org/soap/envelope/) 寻址无 (http://schemas.microsoft.com/ws/2005/05/addressing/none)' 不是 在这种情况下支持。只有 MessageVersion 'EnvelopeNone (http://schemas.microsoft.com/ws/2005/05/envelope/none) 地址无 (http://schemas.microsoft.com/ws/2005/05/addressing/none)' 是 支持。
我不明白这个错误或如何解决它。
【问题讨论】:
标签: wcf iis wcf-binding wcf-security