配置WCF服务(Web.config) - HttpsGetEnabled,HttpsGetUrl

时间:2012-06-20 20:25:08

标签: wcf iis-7 web-config

我正在尝试将带有WCF服务的Silverlight部署到托管服务器。基本上,我和这个家伙有同样的问题: How to configure WCF services to work through HTTPS without HTTP binding? 除了解决方案对我不起作用。

//编辑:我一直错误地粘贴它,但它仍然不起作用。

我尝试过Ladislav Mrnka的答案 - 在Web.config文件中更改了这个:

  <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />

当我导航到服务器上的.svc文件时,仍然会出现可怕的错误:

The HttpsGetEnabled property of ServiceMetadataBehavior is set to true and the
HttpsGetUrl property is a relative address, but there is no https base address.
Either supply an https base address or set HttpsGetUrl to an absolute address.

3 个答案:

答案 0 :(得分:15)

  

现在它应该是正确的,我只是改变了httpGetEnabled和   httpsGetEnabled在适当的位置(它已经在配置文件中)。   但我仍然得到错误。我应该指定HttpsGetUrl   某处?在哪里?

是的,请参阅here

应该是:

<behaviors>
 <serviceBehaviors>
  <behavior name="NewBehavior">
    <serviceMetadata httpsGetEnabled="true" 
     httpsGetUrl="https://myComputerName/myEndpoint" />
  </behavior>
 </serviceBehaviors>
</behaviors>

答案 1 :(得分:0)

在配置中,根据您设置httpsGetEnabled =“ true”的行为, 还要设置httpsGetUrl =“ https:// UserSystemName / EndPointName”并解决问题。

<behaviors>
  <serviceBehaviors>
    <behavior name="mexBehaviour">
      <serviceMetadata httpsGetEnabled="true" httpsGetUrl="https:///UserSystemName/EndPointName"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

答案 2 :(得分:0)

发生此错误是因为设置在逻辑上是错误的。如果启用httpsGetEnabled手段,则允许客户端通过https检索元数据。而且,如果您不提供有关https的URL,则客户端如何从https中检索元数据。因此,错误消息会提醒您提供一个URL。

Either supply an https base address or set HttpsGetUrl to an absolute address.

您有三个选择。

  1. 像上面显示的其他答案一样提供httpsGetUrl
  2. 通过IIS绑定地址

Bindings Site Bindings

(如果您仍在Visual Studio中进行开发,则只需使用SSL启用模式进行脱胶) SSL Enabled

  1. 将httpsGetEnabled设置为false

相关问题