JSON returning null values using WCF Services

Hanbal

New Member
Hi all I am new in JSON and WCF Services. I am trying to call wcf service using JSON and my paramater is one of my data contract class. Here is my Data Contract Class.\[code\]namespace Employee.Services.DataContracts{ using System; using System.Runtime.Serialization; [DataContract] public class ReqDataContract {[DataMember] public long Type { get; set; }[DataMember] public string ID { get; set; }[DataMember] public DateTime? FDate { get; set; }[DataMember]public long? UserID { get; set; } }}\[/code\]Here is myWCF Service function\[code\]public void SaveRequ(ReqDataContract request) { var req=request; }\[/code\]Here is Interface Implementation\[code\][OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] [return: MessageParameter(Name = "ReqData")]void SaveRequ(ReqDataContract request);\[/code\].js File (AJAX Call)\[code\]var selection = "{ \"Type\": 55,\"ID\":'[email protected]' ,\"FDate\":" + null + " ,\"UserID\": 'ASDAS'}";searchData = http://stackoverflow.com/questions/12686346/searchData + (searchData !='' ? "," : "") + selection; if (searchData != null) { searchData = "http://stackoverflow.com/questions/12686346/[" + searchData + "]"; }var searchJSON = jQuery.toJSON(eval("(" + searchData + ")")); var strJSON = searchJSON.toString(); params = '{\"request\":' + strJSON + '}'; $.ajax({ async: false, //To perform synchronize operation to get status type: "POST", url: servicePath + "SaveRequ", dataType: "json", contentType: "application/json; charset=utf-8", data: params, processData: true, success: function (data) { // alert(data.ReqData); }, error: function (xhr, result, id) { alert(xhr.responseText); } });\[/code\]Everything works fine but the problem is i ma getting all the value null in request parameter....Am i missing something?? Please help me in this.
 
Back
Top