Я звоню в службу WCF из ajax и могу заставить ее работать как запрос GET, но не как запрос POST.Итак:
[OperationContract]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public UserObject GetUser(string name)
{
// Add your operation implementation here
var uo = new UserObject() { CustClass = "Guest", fname = "Chris", Email = "chris@Something", IsMobile = false };
uo.fname = name;
return uo;
}
и
var json = { "name": "test" };
$.ajax({ //get user name and customer class
type: "GET",
url: "WritingAnalysisService.svc/GetUser",
data: json,
processData: true,
contentType: "application/json",
timeout: 10000,
dataType: "json",
cache: false,
success: function (data) { //get user name and customer class
customerclass = data.d.custclass;
ffname = data.d.fname;
}
});
работает, но:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public UserObject GetUser(string name)
{
// Add your operation implementation here
var uo = new UserObject() { CustClass = "Guest", fname = "Chris", Email = "chris@Something", IsMobile = false };
uo.fname = name;
return uo;
}
и
$.ajax({ //get user name and customer class
type: "POST",
url: "WritingAnalysisService.svc/GetUser",
data: json,
processData: true,
contentType: "application/json",
timeout: 10000,
dataType: "json",
cache: false,
success: function (data) { //get user name and customer class
customerclass = data.d.custclass;
ffname = data.d.fname;
}
});
нет.Я что-то упустил?Я рву свои волосы здесь.Спасибо