如何配置 WCF 服务通过 HTTPS 工作而无需 HTTP 绑定?

发布于 2024-10-15 10:09:37 字数 296 浏览 2 评论 0原文

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

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

我该如何解决这个问题?

谢谢。

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:

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.

How can I resolve this issue?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝咒 2024-10-22 10:09:38

按如下方式修改您的配置:

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

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>
七秒鱼° 2024-10-22 10:09:38

您需要使用 mexHTTPSBinding 而不是 mexHTTPBinding

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

you need to use mexHTTPSBinding unstead of mexHTTPBinding

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
ま柒月 2024-10-22 10:09:38
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />

由于您将 httpGetEnabled 设置为 true,因此您需要提供 http 地址。而HTTP绑定是一种提供地址的方式。所以如果你删除它,你需要找到另一种方式来提供地址。
以下是提供地址的两种方法。

HttpGetUrl :

 <serviceMetadata httpGetEnabled="true" httpGetUrl="[your service address]" />

HTTP 基地址:

 <host>
    <baseAddresses>
       <add baseAddress="[your service address]" />
    </baseAddresses>
 </host>
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />

Since you set httpGetEnabled to true, you need to provide a http address. And HTTP binding is a way to provide address. So if you remove it, you need to find another way to provide address.
Following are two ways to provide addresses.

HttpGetUrl :

 <serviceMetadata httpGetEnabled="true" httpGetUrl="[your service address]" />

HTTP base address:

 <host>
    <baseAddresses>
       <add baseAddress="[your service address]" />
    </baseAddresses>
 </host>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文