【发布时间】:2012-01-01 05:32:28
【问题描述】:
尝试访问 WCF 服务时出现以下错误。
找不到与绑定 MetadataExchangeHttpBinding 的端点的方案 http 匹配的基地址。注册的基地址方案是 [https]。
这是我的配置
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultHttpBinding"
maxBufferSize="655360"
maxReceivedMessageSize="655360">
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://MySite.com/MyVirtualDir/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="DefaultBehavior"
name="MyWcfService">
<endpoint address="http://MySite.com/MyVirtualDir/MyWcfService.svc"
binding="basicHttpBinding"
bindingConfiguration="DefaultHttpBinding"
contract="MyNamespace.IMyWcfService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true"
policyVersion="Policy15"/>
<serviceDebug httpHelpPageEnabled="true"
includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
这是我的 .scv 文件
<%@ ServiceHost Language="C#" Debug="true" Service="MyWcfService" Factory="MyWcfServiceHostFactory"%>
提供更多可能有用也可能没有帮助的背景
- 该服务在我们的 DEV 环境中运行良好。这个错误只是 发生在我们的 TEST 和 PROD 环境中。唯一可辨别的 我知道的环境之间的区别是 TEST 和 PROD 使用的是 负载平衡器。
- 服务托管在所有环境中的 IIS 5.1 中
- 该服务已在 dot.net 3.5 中编写并由 WebServiceHost 工厂
- 我没有在我的配置文件中指定 https
- 在任何环境中的 IIS 中都没有启用 SSL。匿名访问已启用(稍后将实施安全性)。
我们将不胜感激任何帮助,因为这是我们项目的完整展示。我已经在网上彻底搜索了此问题的解决方案,但似乎与我的特定设置无关。
【问题讨论】:
-
您显然已经意识到这一点,但错误 really 表明以某种方式需要 https。但是由于该错误与元数据交换有关,您可以尝试检查是否禁用该功能可以让您访问该服务,然后稍后尝试消除元数据问题。也许您还应该检查元日期交换是否存在任何继承设置。
-
如果您认为负载均衡器可能导致问题,那么您可以组织一个绕过它的测试吗?
-
你也可以粘贴客户端配置吗?
-
我确实尝试绕过负载均衡器并直接连接到两个节点,但得到了同样的错误。此外,这是第一个托管的 WCF 服务(目前所有其他 Web 服务都是 asmx),所以我认为没有任何其他的 mex 绑定配置被继承。
-
顺便说一句。感谢您的快速和有益的答复。不幸的是,我必须经历一个漫长的变更控制过程才能部署到有问题的环境,而且我也没有任何直接访问它们的权限,因此我无法快速测试您的建议。接下来我将尝试禁用 mex 绑定。
标签: c# wcf web-config wcf-binding iis-5