Ok, this is one of these basic questions, but I've googled and debugged now for two hours and the error escapes me.
Simple scenario: WCF service with methods with parameters which I'd like to call through jquery. I can call methods without params alright, but with params, the call never makes it to my breakpoint in .NET.
ServerCode:
[ServiceContract(Namespace = "http://www.myhost.de")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MyService
{
[OperationContract]
public int TestMeWithParam(int lastId)
{
return lastId;
}
[OperationContract]
public int TestMe()
{
return 5;
}
}
Javascript code
function BaseServiceCall(serviceName, dataInput, successCB, errorCB) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: BaseUrl + "Services/MyService.svc/" + serviceName,
data: dataInput,
dataType: "json",
timeout: 2000,
success: successCB,
error: errorCB
});
}
function ServiceGetMessages(lastMessageId, successCB, errorCB) {
BaseServiceCall("TestMeWithParam", "{'lastId':'17'}", successCB, errorCB);
//BaseServiceCall("TestMe", "", successCB, errorCB);
}
So, if I call the TestMe service it returns 5. It works. TestMeWithParam never gets called.
What's going on?