使用 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 未返回主机 header ,因此 WCF 正在猜测并返回机器名称。
当然,IIS7 不允许我将主机 header 添加到使用 SSL 的站点。我用谷歌搜索并看到其他人使用 appcmd 设置主机 header ,就像这样
appcmd set site/site.name:/+bindings.[protocol='https',bindingInformation='*:443:']
试了一下,告诉我网站已经修改
但是我没有修改现有的 SSL 绑定(bind),而是得到一个具有主机名但没有附加证书的附加 绑定(bind)。任何通过 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"/>
最佳答案
如果命令行不起作用,您可以在 UI 中执行。您将需要使用证书的友好名称。链接如下。
关于wcf - 部署 WCF - 需要在 SSL 站点上设置主机 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6674158/