【问题标题】:How can I use a WCF with a SSL Certificate HTTPS IIS如何将 WCF 与 SSL 证书 HTTPS IIS 一起使用
【发布时间】:2017-06-12 10:05:14
【问题描述】:

我有几天的时间试图解决我的 WCF 的问题,当绑定是 HTTP 时它确实有效。但是,一旦我购买了 SSL 证书并将我的网站配置为在 HTTPS 中运行,当我更改 IIS 上的绑定时,我的应用程序就无法使用。

我收到以下错误消息: Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].

我的 web.config

<services>
  <service behaviorConfiguration="WebServiceBehavior" name="WcfService1.Service">
    <endpoint address="" behaviorConfiguration="jsonBehavior" binding="webHttpBinding"
              bindingConfiguration="webHttpBindingWithJsonP" contract="WcfService1.IService"/>
    <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IService" />
  </service>
</services>

<behaviors>
  <endpointBehaviors>
    <behavior name="jsonBehavior">
      <webHttp helpEnabled="true"/>
    </behavior>
  </endpointBehaviors>

  <serviceBehaviors>
    <behavior name="WebServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <webHttpBinding>
    <binding name="webHttpBindingWithJsonP"
             crossDomainScriptAccessEnabled="true"   />

  </webHttpBinding>

</bindings>

可以让我的 WCF 使用 HTTPS 吗?

【问题讨论】:

    标签: asp.net wcf web service


    【解决方案1】:

    这对https://msdn.microsoft.com/en-us/library/hh556232(v=vs.110).aspx 有帮助吗?它包括一个完整的 https 配置示例。

    特别是我认为您需要security mode=Transport 才能使 SSL 工作:

    <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true">
        <security mode="Transport">
          <transport clientCredentialType="None"/>
        </security>
    </binding>
    

    【讨论】:

      【解决方案2】:

      克里斯·F·卡罗尔

      感谢您抽出宝贵时间回复我的帖子。

      终于可以自己解决了。

      这是我在 HTTPS 和 HTTP 上所做的工作: < serviceHostingEnvironment multipleSiteBindingEnabled="true" aspNetCompatibilityEnabled="false" />

      上面的代码位于:

      <system.serviceModel>
      

      【讨论】:

        猜你喜欢
        • 2011-04-08
        • 1970-01-01
        • 2014-09-09
        • 2013-08-03
        • 2011-02-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-23
        相关资源
        最近更新 更多