【问题标题】:Enable HTTPS on WCF rest webservice在 WCF REST Web 服务上启用 HTTPS
【发布时间】:2019-03-31 00:49:15
【问题描述】:

在 WCF REST Web 服务上启用 HTTPS

我已经尝试了多种配置,但我无法让我的 WCF 休息网络服务通过 HTTPS 工作。我收到 500 个内部错误或 400 个错误请求。

我在 IIS 中添加了一个新网站,绑定到端口 80 和 443。然后,启用 http/https 协议。

这是我的 Web.config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
   <service name="RestService.MyService">
     <endpoint address="https://mywebsite.com"
       binding="webHttpBinding" contract="RestService.IMyService" />
   </service>
 </services>
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.5" sku=".NETFramework,Version=v4.5.1"/>
  </startup>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information,ActivityTracing"
        propagateActivity="true">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="xml" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\logs\TracingAndLogging-service.svclog" type="System.Diagnostics.XmlWriterTraceListener"
        name="xml" />
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>
</configuration>

【问题讨论】:

    标签: wcf iis iis-6 wcf-binding wcf-rest


    【解决方案1】:

    尝试将以下绑定配置添加到端点。

    <services>
      <service name="WcfServiceFile.Service1">
        <endpoint address="" binding="webHttpBinding" contract="WcfServiceFile.IService1" behaviorConfiguration="beh" bindingConfiguration="myBinding">
        </endpoint>
      </service>
    </services>
    <bindings>
      <webHttpBinding >
        <binding name="myBinding" >
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </webHttpBinding>
    

    不要忘记将绑定配置应用到端点以使其生效。
    结果。 由于自签名证书,连接不安全。 如果问题仍然存在,请随时与我联系。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2011-08-03
      相关资源
      最近更新 更多