34

我正在尝试将 WCF 服务部署到我的服务器,托管在 IIS 中。自然它可以在我的机器上运行:)

但是当我部署它时,我收到以下错误:

这个集合已经包含一个带有 http 方案的地址。此集合中的每个方案最多可以有一个地址。

对此进行谷歌搜索,我发现我必须将 serviceHostingEnvironment 元素放入 web.config 文件中:

<serviceHostingEnvironment>
  <baseAddressPrefixFilters>
    <add prefix="http://mywebsiteurl"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

但是一旦我这样做了,我会得到以下信息:

找不到与绑定 BasicHttpBinding 的终结点的方案 http 匹配的基地址。注册的基地址方案是 [https]。

似乎它不知道基地址是什么,但我该如何指定呢?这是我的 web.config 文件的相关部分:

<system.serviceModel>
  <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
      <add prefix="http://mywebsiteurl"/>
    </baseAddressPrefixFilters>
  </serviceHostingEnvironment>

  <behaviors>
    <serviceBehaviors>
      <behavior name="WcfPortalBehavior">
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IWcfPortal"
               maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
               receiveTimeout="00:10:00" sendTimeout="00:10:00"
               openTimeout="00:10:00" closeTimeout="00:10:00">
        <readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647"
               maxStringContentLength="2147483647"/>
      </binding>
    </basicHttpBinding>
  </bindings>

  <services>
    <service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
      <endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal"
      bindingConfiguration="BasicHttpBinding_IWcfPortal">
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
  </services>
</system.serviceModel>

任何人都可以阐明发生了什么以及如何解决它?

4

9 回答 9

44

尝试将安全模式从“传输”更改为“无”。

      <!-- Transport security mode requires IIS to have a
           certificate configured for SSL. See readme for
           more information on how to set this up. -->
      <security mode="None">
于 2011-03-30T10:36:22.777 回答
5

我必须对站点/应用程序的 IIS 配置做两件事。我的问题与让 net.tcp 在 IIS 网站应用程序中工作有关:

第一的:

  1. 右键单击 IIS 应用程序名称。
  2. 管理网站
  3. 高级设置
  4. 将启用的协议设置为“http,net.tcp”

第二:

  1. 在 Manager 右侧的 Actions 菜单下,单击 Bindings...
  2. 点击添加
  3. 将类型更改为“net.tcp”
  4. 将绑定信息设置为 {open port number}:*
  5. 好的
于 2011-07-21T20:14:30.637 回答
4

如果您想在 web.config 中使用 baseAddressPrefixFilters,您还必须设置 IIS (6)。这帮助了我:

1/ 在 IIS 中找到您的站点。2/ 属性/网站(选项卡)/IP 地址 -> 高级按钮 3/ 在您将在 web.config 中使用的同一端口上添加新主机头。

于 2010-05-12T17:01:34.733 回答
4

您的 IIS 是否有可能被配置为在连接到您的站点/应用程序时需要 SSL?

于 2009-05-16T17:26:05.390 回答
2

只有列表中的第一个基地址将被接管(来自 IIS)。在 .NET4 之前,每个方案不能有多个基地址。

于 2011-09-07T13:43:13.443 回答
1

解决方案是在 Web.Config 文件中定义自定义绑定并将安全模式设置为“传输”。然后,您只需要使用端点定义中的 bindingConfiguration 属性来指向您的自定义绑定。

请参阅此处:Scott 的博客:HTTPS 所需的 WCF 绑定

于 2012-03-22T05:41:17.777 回答
0

如果托管在 IIS 中,则无需指定基地址,它将是虚拟目录的地址。

于 2009-05-18T09:36:20.893 回答
0

应该有一种方法可以通过外部配置部分和一个额外的部署步骤轻松解决这个问题,该步骤将特定于部署的外部 .config 文件放入已知位置。我们通常使用此解决方案来处理我们不同部署环境(暂存、QA、生产等)的不同服务器配置,如果没有发生特殊副本,我们的“开发箱”是默认设置。

于 2010-03-19T02:50:54.213 回答
0

确认我的修复:

在您的 web.config 文件中,您应该将其配置为如下所示:

<system.serviceModel >
    <serviceHostingEnvironment configSource=".\Configurations\ServiceHosting.config" />
    ...

然后,构建一个如下所示的文件夹结构:

/web.config
/Configurations/ServiceHosting.config
/Configurations/Deploy/ServiceHosting.config

基本的 serviceHosting.config 应该如下所示:

<?xml version="1.0"?>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
    <baseAddressPrefixFilters>
    </baseAddressPrefixFilters>
</serviceHostingEnvironment>

而 /Deploy 中的那个看起来像这样:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
    <baseAddressPrefixFilters>
        <add prefix="http://myappname.web707.discountasp.net"/>
    </baseAddressPrefixFilters>
</serviceHostingEnvironment>

除此之外,您还需要添加手动或自动部署步骤,以将文件从 /Deploy 复制到 /Configurations 中的文件之上。这对于服务地址和连接字符串非常有效,并且可以节省其他解决方法的工作量。

如果您不喜欢这种方法(它可以很好地扩展到农场,但在单台机器上较弱),您可以考虑在主机机器上的服务部署上添加一个 web.config 文件,并将 serviceHostingEnvironment 节点放在那里。它应该为您级联。

于 2010-03-19T03:48:39.620 回答