Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have written a simple HTML page where I am passing JSON object to WCF service. When I run the service in debug mode (VS2012) and call the page from IE 10, Debugger gets called but in a parameter place object passed is null..

jQuery Code:
Java
var objJSON = {
   "postJSON": {
      "id": "0",
      "emp_name": "abc",
      "emp_city": "delhi",
      "emp_addr": "india"
   }
};

$.ajax({
   type: "POST",
   url: "http://localhost:8080/MainService.svc/updatedata",
   data: JSON.stringify(objJSON),
   dataType: "json",
   contentType: "application/json; charset=utf-8",
   processData:true,
   success: function (objSuccess) {
      console.log("success");
      console.log(JSON.stringify(objSuccess));
   }
   ,
   error: function (objError) {
      console.log("error");
      alert(JSON.stringify(objError));
   }
});


WCF Service Code:

MainService.svc.cs
Java
public ClsEmployee UpdateEmployee(ClsEmployee objEmployee)
{
   new ClsTransaction().updateRecord(objEmployee);


Service Contract
Java
[OperationContract]
   [WebInvoke(Method = "POST", 
      ResponseFormat = WebMessageFormat.Json, 
      RequestFormat = WebMessageFormat.Json, 
      BodyStyle = WebMessageBodyStyle.Wrapped, 
      UriTemplate = "updatedata")]
   ClsEmployee UpdateEmployee(ClsEmployee postJSON);
}
Posted
Updated 30-May-14 9:43am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900