添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Ajax – 500 System.ServiceModel.ServiceActivationException when making an Ajax call to WCF rest service

ajax wcf

Ajax Call:

   $.ajax({
        type: "POST",
        url: "http://SomeService/ServiceName.svc/GetSearchResults",
        data: JSON.stringify({ parameters: serviceParameters }),
        contentType: "application/json; charset=utf-8",
        dataType: "XML",
        success: function (response) {
            $("#xmlText").text(response.xml);
        error: function (msg) {
            alert(msg.toString);

WCF Interface:

[OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Json,
                    UriTemplate = "GetSearchResults")]
        XElement GetSearchResults(inputParameters parameters);
        [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "getFile")]
        Stream GetFile(DocInfo info);

Web.config:

 <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
  </system.web>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 <system.serviceModel>
   <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
   </serviceHostingEnvironment>
   <standardEndpoints>
     <webHttpEndpoint>
       <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
     </webHttpEndpoint>
   </standardEndpoints>
 </system.serviceModel>

The service is hosted on IIS6.

When I call the service I get the following error message:

500 System.ServiceModel.ServiceActivationException

I can call the GetFile method and get the response stream but I get the error message when calling GetSearchResults.

Any help will be appreciated.

I encountered this error for the reason mentioned below

Memory gates checking failed because the free memory (258187264 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.