当将SSL应用于网站时,WCF不起作用



我已将SSL应用于我的域,但是在那之后,我的WCF停止工作。我尝试添加mexhttpsmapping,但对我不起作用。

我正在使用WCF以JSON格式获取数据。我的web.config:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" 
multipleSiteBindingsEnabled="true" />
<bindings>
  <webHttpBinding>
    <binding name="restLargeBinding" maxBufferPoolSize="2147483647" 
maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" 
transferMode="Streamed">
      <readerQuotas maxStringContentLength="2147483647"/>
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="myWebEndPointBehaviour">
      <webHttp automaticFormatSelectionEnabled="true" 
defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Json" 
helpEnabled="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="myServiceBehaviour">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="DemoWCFServiceForVision.Service1" 
behaviorConfiguration="myServiceBehaviour">
    <endpoint address="" contract="DemoWCFServiceForVision.IService1" 
binding="webHttpBinding" bindingConfiguration="restLargeBinding" 
behaviorConfiguration="myWebEndPointBehaviour"/>
    <endpoint address="mex" contract="DemoWCFServiceForVision.IService1" 
binding="mexHttpBinding"/>
  </service>
</services>
<protocolMapping>
  <add binding="basicHttpBinding" scheme="https"/>
</protocolMapping>
</system.serviceModel>
<system.webServer>
 <rewrite>
    <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
            <match url="(.*)" /> 
            <conditions> 
                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            </conditions> 
            <action type="Redirect" redirectType="Permanent" 
url="https://{HTTP_HOST}/{R:1}" />
        </rule>   
    </rules>
</rewrite>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>

您需要在WebHTPBinding上配置传输层安全性和HTTPS服务端点。您可以在以下答复中参考示例。
WCF服务没有通过HTTPS击中Postman
随时让我知道是否有我可以帮助的。

最新更新