0

使用 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 的站点。我用谷歌搜索并看到其他人使用 appcmd 设置主机标头,如下所示

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

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

但是,我没有修改现有的 SSL 绑定,而是获得了一个具有主机名但没有附加证书的附加绑定。任何通过 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"/>

4

1 回答 1

0

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

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

于 2011-07-13T16:22:14.997 回答