我有一个基于WCF的REST Web服务并通过HTTP工作。
如果我尝试通过HTTPS访问它,我会收到404错误。我需要HTTPS才能正常工作,因为该服务主要处理用户在浏览器中通过AJAX进行的状态更改。如果我尝试使用.ajax
调用Web服务,则会收到错误。
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>