【问题标题】:BasicHttpBinding fails when sharing endpoint with WsHttpBinding - The server certificate is not provided与 WsHttpBinding 共享端点时 BasicHttpBinding 失败 - 未提供服务器证书
【发布时间】:2013-06-17 13:25:04
【问题描述】:

我有一个 WCF 服务端点,它使用不同地址的 WsHttpBinding 和 BasicHttpBinding 来允许它们共享端点。 BasicHttpBinding 没有安全性。当我的服务和客户端在同一台机器上时,BasicHttpBinding 工作正常。当它们在不同的机器上时,BasicHttpBinding 失败,并且我在服务的跟踪日志中收到此错误:未提供服务证书。在 ServiceCredentials 中指定服务证书。

如果我从服务的配置中删除 WsHttpBinding,错误就会停止发生。

服务的 web.config:

<bindings>
    <basicHttpBinding>
        <binding name="MyBasicBinding"
                  maxBufferPoolSize="5242880"
                  maxReceivedMessageSize="5242880" />
    </basicHttpBinding>
    <wsHttpBinding>
        <binding name="MyWsBinding"
                  bypassProxyOnLocal="false"
                  hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="5242880"
                  maxReceivedMessageSize="5242880"
                  allowCookies="false">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <security mode="Message">
                <message clientCredentialType="None" /> 
            </security>
        </binding>
    </wsHttpBinding>
</bindings>

<services>
    <service name="MyService">
        <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="MyBasicBinding"
           contract="MyFramework.IMyService" bindingNamespace="http://MyFramework/Services/"/>

        <!-- The basic binding fails when the WS binding is present.
             If I remove the WS binding, the basic binding will work. -->
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyWsBinding"
           contract="MyFramework.IMyService" bindingNamespace="http://MyFramework/Services/"/>
    </service>
</services>

仅供参考,我为基本绑定使用了不同的地址,这允许 2 个绑定共享相同的端点。 WsHttpBinding 的 URL 是 http://server/MyService.svc,BasicHttpBinding 的 URL 是 http://server/MyService.svc/basic

为什么 WsHttpBinding 的存在会强制 BasicHttpBinding 期待证书?

【问题讨论】:

    标签: wcf wcf-binding wcf-security


    【解决方案1】:

    当服务启动时,它需要确保所有端点都有效。由于其中一个端点(WSHttp 之一)使用证书身份验证,如果未定义此证书,服务器将不会启动。所以错误与BasicHttp无关。这仍然不能解释为什么如果在同一台机器上一切正常,请检查是否使用完全相同的配置。

    【讨论】:

    • 谢谢亚龙!我的解决方案是为基本和 WS 创建 2 个 SVC 文件。
    猜你喜欢
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 2012-03-24
    • 2023-03-24
    • 2013-04-26
    • 2018-10-20
    • 2013-06-17
    • 1970-01-01
    相关资源
    最近更新 更多