Bla*_*man 32 iis ssl configuration wcf web-services
我的WCF serice似乎使用的是计算机名而不是域名.当我查看MyService.svc?wsdl链接时,它显示我的计算机名称.
我在哪里可以在web.config中添加我的域名?端点地址,基址还是身份?
注意:我正在使用SSL,所以必须这样做 https://www.example.com/myservice.svc
nic*_*lot 27
在某些情况下,WCF 4.0使用请求标头的新配置选项解决了此问题:
<behaviors>
<serviceBehaviors>
<behavior name="AutoVaultUploadBehavior">
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
Run Code Online (Sandbox Code Playgroud)
对于IIS7,不要将其添加到web.config,而是添加到IIS配置文件.
首先编辑您的网站的绑定,以便HTTP协议指定主机名(如果您还没有) - 这将确保它在HTTP下获得正确的名称.
导航到C:\ Windows\System32\inetsrv\config并打开applicationHost.config
寻找网站部分.您将看到类似以下内容的内容
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:puck" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
<binding protocol="http" bindingInformation="*:80:puck.idunno.org" />
<binding protocol="http" bindingInformation="*:80:localhost" />
<binding protocol="https" bindingInformation="*:443:" />
</bindings>
</site>
....
</sites>
Run Code Online (Sandbox Code Playgroud)
您可以看到http协议的绑定指定了主机头,但https没有.当您进行Web浏览时,您无法通过HTTPS使用主机标头,但WCF在生成WSDL时仍然使用它 - 如果找不到它,它将回退到计算机名称.
所以你需要做的就是像这样编辑HTTPS绑定
<binding protocol="https" bindingInformation="*:443:puck" />
Run Code Online (Sandbox Code Playgroud)
将正确的FQDN附加到绑定信息的末尾.重置IIS和WCF应该立即得到它.
IIS已经发布了IIS6解决方案
小智 8
如此链接中所述,WCF使用计算机名称而不是IP地址,无法解析
它解决了我的问题,也许是因为我在同一台主机上有多个网站,而且非常简单.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
</ system.serviceModel>
我们使用WCFExtras来更改主机的名称。
WCFExtras 是一个小型开源库,允许您编写以下代码来更改主机名:
<behaviors>
<endpointBehaviors>
<behavior name="xxx">
<wsdlExtensions location="http://some-hostname-visible-from-outside/path-to-a-service/service.svc" singleFile="True" />
</behavior>
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28018 次 |
| 最近记录: |