我正在尝试让 WCF Web 服务与 SSL 一起工作,正如您想象的那样 works on my machine ,但是当我在生产环境中运行它时,我得到的是:
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].
尽管与这个问题纠缠了好几个小时,但我仍然不太清楚这个错误消息的实际含义 - 谷歌搜索这个错误消息发现很多人说我应该在我的端点配置中指定一个地址或添加一个基地址然而,为了我的服务:
- 我的服务在没有指定禁用 SSL 的情况下运行得非常好
- 事实上,我的服务在另一台机器上使用完全相同的配置 SSL 时工作得很好
- 此外,我找到了a post这可靠地告诉我,在 IIS 下托管时,无论如何都会忽略基址。
您可能会说,我目前感到非常沮丧,因为我完全没有完成我认为是相对简单的任务,所以:
- 此错误消息的实际含义是什么?
- 在 IIS 下托管时如何确定基址?
- 我在哪里可以找到可靠、易于理解的文档,了解我复制粘贴的所有配置的实际含义?
- 我需要做什么才能让我的服务真正发挥作用?
我的 web.config 中有趣的部分是:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="MyService" behaviorConfiguration="MyBehavior">
<endpoint binding="basicHttpBinding" bindingConfiguration="SecureTransport"
bindingNamespace="http://MyNamespace/Service" name="Basic"
contract="MyContract" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="SecureTransport">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
最佳答案
一件事是场外但可能导致此消息的是服务器上的 SSL 证书是否已过期或设置不正确。
关于WCF 错误 - 找不到与方案匹配的基地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3177281/