C# WCF JSON服务,通过jquery调用2个方法。GET方法有效,POST方法返回404错误

C# WCF JSON服务,通过jquery调用2个方法。GET方法有效,POST方法返回404错误,c#,jquery,json,wcf,C#,Jquery,Json,Wcf,我有一个简单的WCF服务,具有以下接口: [ServiceContract] public interface IPageService { [OperationContract] [WebGet(UriTemplate = "/GetPage/{pageNumber}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] Page GetPage(string

我有一个简单的WCF服务,具有以下接口:

[ServiceContract]
public interface IPageService {

    [OperationContract]
    [WebGet(UriTemplate = "/GetPage/{pageNumber}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Page GetPage(string pageNumber);

    [OperationContract]
    [WebInvoke(UriTemplate = "/SetPages", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    string SetPages(Page[] pages);
}
配置文件的system.serviceModel部分如下所示:

<system.serviceModel>
  <protocolMapping>
    <add scheme="http" binding="webHttpBinding"/>
  </protocolMapping>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
      <behavior>
        <webHttp/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
使用以下JavaScript调用SetPages方法返回404错误:

$.ajax({
    cache: false,
    url: 'http://localhost/Test/PageService.svc/SavePages', 
    type: 'POST',
    data: '[{...}]', 
    dateType: 'json',
    contentType: 'application/json',
    processData: false,
    success: function(result) { 
        // do success stuff 
    }, 
    error: function(req, status, error) { 
        // do error stuff 
    } 
});

我已经尝试了ajax调用中几乎所有的参数组合,但没有任何区别。我已经使用了配置文件,并尝试了这里和各种博客中建议的各种配置,但所做的只是使这两种方法返回AddressFilter或ContractFilter不匹配。我错过了什么?让这两种方法都工作的最快/最简单的方法是什么?

根据您发布的代码,jscript调用SavePages方法,但在服务器端,post方法具有名称SetPages

啊!我在这上面浪费了一整天,我肯定我已经检查过很多次了。非常感谢。
$.ajax({
    cache: false,
    url: 'http://localhost/Test/PageService.svc/SavePages', 
    type: 'POST',
    data: '[{...}]', 
    dateType: 'json',
    contentType: 'application/json',
    processData: false,
    success: function(result) { 
        // do success stuff 
    }, 
    error: function(req, status, error) { 
        // do error stuff 
    } 
});