更改 WCF 服务以要求 SSL

发布于 2024-10-20 23:19:11 字数 1698 浏览 6 评论 0原文

我有一个 WCF 服务,在 http 绑定上运行良好。我尝试更新它以使用 SSL,但收到以下错误:

“无法找到与绑定 WSHttpBinding 的端点的方案 http 相匹配的基地址。注册的基地址方案是 [https]。”

仅当我在 IIS 7.5 中将站点设置为“需要 SSL”时才会发生这种情况,如果我取消选中它,则它可以正常工作。

这是我的配置,

<system.serviceModel>    
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior" >
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      <!-- 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" />
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
    </binding>
  </wsHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="WcfService1.Service1">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/WcfService1/"/>
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
      name="wsHttpEndpoint" contract="WcfService1.IService1" />
    <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
      name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我已经尝试过各种方法,但似乎没有任何帮助,非常感谢任何帮助!

I have a WCF service which was running fine on a http binding. I've tried to update this to use SSL but i am getting the following error:

"Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [https]."

This only occurs when i set the site to "Require SSL" in IIS 7.5 if I uncheck it it works fine.

Here's my config

<system.serviceModel>    
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior" >
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      <!-- 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" />
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
    </binding>
  </wsHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="WcfService1.Service1">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/WcfService1/"/>
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
      name="wsHttpEndpoint" contract="WcfService1.IService1" />
    <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
      name="MexHttpsBindingEndpoint" contract="IMetadataExchange" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

I've tried allsorts and nothing seems to get me there, any help is greatly appreciated!

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

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

发布评论

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

评论(2

土豪 2024-10-27 23:19:12

除了更改绑定配置设置(如 Ladislav 提到的)...将基地址中的 HTTP 更改为 HTTPS。

In addition to changing the binding configuration settings (as Ladislav mentioned)... Change HTTP in the base address to HTTPS.

乜一 2024-10-27 23:19:11

修改您的绑定配置:

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
      <security mode="Transport" />
    </binding>
  </wsHttpBinding>
</bindings>

并通过将其 bindingConfiguration 属性设置为配置名称来引用您的端点中的配置。

<endpoint address="" binding="wsHttpBinding" 
  bindingConfiguration="wsHttpEndpointBinding"
  name="wsHttpEndpoint" contract="WcfService1.IService1" />

您还可以删除包含基地址的 host 部分,因为在 IIS 中托管时不会使用它。

Modify your binding configuration:

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpEndpointBinding">
      <security mode="Transport" />
    </binding>
  </wsHttpBinding>
</bindings>

And reference that configuration in your endpoint by setting its bindingConfiguration attribute to the name of configuration.

<endpoint address="" binding="wsHttpBinding" 
  bindingConfiguration="wsHttpEndpointBinding"
  name="wsHttpEndpoint" contract="WcfService1.IService1" />

You can also delete the host section with base address because it is not used when hosting in IIS.

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