【问题标题】:Deploying WCF - Need to Set the Host Headers on an SSL Site部署 WCF - 需要在 SSL 站点上设置主机标头
【发布时间】:2011-10-04 04:30:14
【问题描述】:

使用 Visual Studio 2010 / .NET 4.0

我已经做了好几个小时了,但我会尽量具体一点。

我正在将 WCF 4.0 服务部署到 IIS 7。它在 http 下运行良好。我可以从 Visual Studio 中针对 WCF 服务添加服务引用,并针对它添加代码。

当然问题是服务需要在https下运行。

我已经设法处理了 web.config 文件,因此它可以在 https 下运行(至少我可以在浏览器中看到 .svc 和 ?wsdl 显示)。

当然 IIS 返回的是机器名,而不是整个 wsdl 中的域名。

所以当我尝试添加服务引用时,我得到了类似这样的结果。

文档已被理解,但无法处理。 - WSDL 文档包含无法解析的链接。 - 下载“https://machinename/MyServiceName.svc?xsd=xsd0”时出错。 - 无法解析远程名称:'machinename'

我知道问题在于 IIS 没有返回主机标头,因此 WCF 猜测并返回机器名称。

当然,IIS7 不允许我将主机头添加到使用 SSL 的站点。我在 Google 上搜索过,并看到其他人使用 appcmd 设置主机标头,类似于这样

appcmd 设置站点/site.name: /+bindings.[protocol='https',bindingInformation='*:443:']

试过了,它告诉我网站已经被修改了

但我没有修改现有的 SSL 绑定,而是得到一个 additional 绑定,它有一个主机名,但没有附加证书。任何通过 IIS UI 选择 SSL 的尝试都会清除主机名。我正在使用来自 GoDaddy 的通配符证书

1) 有人看到 appcmd 有这个问题吗?对如何解决有任何想法。 2) 我可以在 webconfig.xml 中设置域名吗?迄今为止,我所做的所有尝试都产生了各种 IIS 黄屏死机,抱怨一个或另一个参数。我附上一份供您娱乐和建议的副本。

<services>
  <service name ="NameThisService" behaviorConfiguration="TheDefaultBehaviour">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="webBinding" contract="IService" >
    </endpoint>


  </service>
</services>

<bindings>
  <wsHttpBinding>
    <binding name="webBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings >


<behaviors>
  <serviceBehaviors>
    <behavior name="TheDefaultBehaviour">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpsGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>

    </behavior>
  </serviceBehaviors>
</behaviors>




<serviceHostingEnvironment multipleSiteBindingsEnabled="false"/>

【问题讨论】:

    标签: wcf iis-7 ssl appcmd hostheaders


    【解决方案1】:

    如果命令行不起作用,您可以在 UI 中执行。您将需要使用证书的友好名称。链接如下。

    http://blog.armgasys.com/?p=80

    【讨论】:

      最近更新 更多