2

我有一个基于 WCF 的 REST Web 服务并通过 HTTP 工作。

如果我尝试通过 HTTPS 访问它,我会收到 404 错误。我需要 HTTPS 才能正常工作,因为该服务将主要处理用户在浏览器中通过 AJAX 所做的状态更改。如果我尝试调用 Web 服务,.ajax我会收到错误消息。

http://site/svc/core.svc/dowork == working

https://site/svc/core.svc/dowork == 404

这是基本代码:

    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)]
    string DoWork();

    public string DoWork()
    {
        return "hullo";
    }

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <webHttpBinding>
        <binding name="secureBinding">
          <security mode="Transport"/>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="webHttpBinding" bindingConfiguration="secureBinding" scheme="https"/>
    </protocolMapping>
    <services>
      <service name="Fusion.core" behaviorConfiguration="Fusion.CoreBehavior" >
        <endpoint contract="Fusion.Icore" binding="webHttpBinding" behaviorConfiguration="webBehavior" address="" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Fusion.CoreBehavior">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
4

0 回答 0