.net 如何配置 WCF 服务以在没有 HTTP 绑定的情况下通过 HTTPS 工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4863590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 15:12:02  来源:igfitidea点击:

How to configure WCF services to work through HTTPS without HTTP binding?

.netwcfiisweb-config

提问by Dmitrii

I have configured my WCF services to work with SSL but it works ONLY if the HTTP binding exists in the IIS Web Site. When the HTTP binding not exists and exists only HTTPS binding I get the following error:

我已将 WCF 服务配置为使用 SSL,但仅当 IIS 网站中存在 HTTP 绑定时它才有效。当 HTTP 绑定不存在且仅存在 HTTPS 绑定时,我收到以下错误:

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

ServiceMetadataBehavior 的 HttpGetEnabled 属性设置为 true,HttpGetUrl 属性是相对地址,但没有 http 基地址。要么提供 http 基地址,要么将 HttpGetUrl 设置为绝对地址。

How can I resolve this issue?

我该如何解决这个问题?

Thanks.

谢谢。

回答by Ladislav Mrnka

Modify your configuration this way:

以这种方式修改您的配置:

<behaviors>
  <serviceBehaviors>
    <behavior> <!-- behavior can have name (must have name in WCF 3.x) -->
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

回答by DesignFirst

you need to use mexHTTPSBinding unstead of mexHTTPBinding

您需要使用 mexHTTPSBinding 而不是 mexHTTPBinding

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />