部署 WCF - 需要在 SSL 站点上设置主机标头
使用 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 set site /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"/>
Using Visual Studio 2010 / .NET 4.0
I've been at this for hours but I'll try to be specific.
I'm deploying a WCF 4.0 Service to IIS 7. It works fine under http. I can add a service reference from Visual Studio against the WCF service and code against it no problem.
Of course the problem is that the service needs to run under https.
I've managed to manhandle the web.config file so it will run under https (at least I can see the .svc and ?wsdl display in the browser).
But of course IIS is returning the machine name, not the domain name throughout the wsdl.
So when I try to add the service reference I get somehting like this.
The document was understood, but it could not be processed.
- The WSDL document contains links that could not be resolved.
- There was an error downloading 'https://machinename/MyServiceName.svc?xsd=xsd0'.
- The remote name could not be resolved: 'machinename'
I know the problem is that IIS is not returning host headers so WCF is guessing and handing back the machine name.
Of course IIS7 won't allow me to add host headers to a site that is using SSL. I've Googled and seen others set host headers with using appcmd something like this
appcmd set site /site.name: /+bindings.[protocol='https',bindingInformation='*:443:']
Tried it and it tells me that the site has been modified
But instead of modifiying the existing SSL binding I get an additional binding that has a host name, but no certificate attached to it. Any attempt to select a SSL through the IIS UI wipes out the hostname. I'm using a wildcard certificate from GoDaddy
1) Anyone see this problem with appcmd? Have any ideas on how to solve.
2) Can I set the domain name in the webconfig. All my attempts to do so to date have produced various IIS Yellow Screens of Death complaining about one parameter or another. I include a copy for your entertainment and suggestions.
<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"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果命令行不起作用,您可以在 UI 中执行此操作。您将需要尝试使用证书的友好名称。链接如下。
http://blog.armgasys.com/?p=80
If the command line doesn't work you CAN do it in the UI. You will need to play around with the Friendly name of the certificate. Link below.
http://blog.armgasys.com/?p=80