ajax'den bir WCF hizmetini arıyorum ve bir GET isteği olarak çalışmasını ancak bir POST isteği olarak çalışmasını sağlayabiliyorum. Yani:ajax POST çağrısı WCF hizmetine sorun
[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 = "[email protected]", IsMobile = false };
uo.fname = name;
return uo;
}
ve
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;
}
});
çalışır ancak:
[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 = "[email protected]", IsMobile = false };
uo.fname = name;
return uo;
}
ve
$.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;
}
});
yapmaz. Basit bir şey mi eksik? Saçlarımı yırtıyorum. Teşekkürler
'Yapmıyor. Bu ne demek? Hata mı alıyorsun? Servis hiç çağrılmıyor mu? java komut hatası aldın mı? Fiddler'da istek ve cevap nedir? – Aliostad