[OperationContract][WebInvoke(UriTemplate="/SaveUserData",Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]string SaveUserData(CustomerDetails CustomerDetail); [DataContract]public class CustomerDetails{ [DataMember] public string First_Name { get; set; } [DataMember] public string Last_Name { get; set; } [DataMember] public string Mobile_No { get; set; } [DataMember] public string Email_ID { get; set; } [DataMember] public string Address { get; set; } [DataMember] public string City { get; set; } [DataMember] public string Pincode { get; set; }} function POSTMethodCall() {var Customer = {"CustomerDetails":{ "First_name": "My", "Last_name": "Test", "Mobile_No": "1234567890", "Email_ID": "[email protected]", "Address": "XYZ ABCD", "City": "ASDFGH", "Pincode": "400708"}};var st = JSON.stringify(Customer);debugger;$.ajax({type: "POST",url: "http://www.abc.co.in/Service1.svc/SaveUserData",Data: st,contentType: "application/json",dataType: "json",success: function (Data) {// Play with response returned in JSON format},error: function(Data){alert("Error:"+Data)}});
[OperationContract]
[WebInvoke(UriTemplate="/SaveUserData",
Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
string SaveUserData(CustomerDetails CustomerDetail); [DataContract]public class CustomerDetails{ [DataMember] public string First_Name { get; set; } [DataMember] public string Last_Name { get; set; } [DataMember] public string Mobile_No { get; set; } [DataMember] public string Email_ID { get; set; } [DataMember] public string Address { get; set; } [DataMember] public string City { get; set; } [DataMember] public string Pincode { get; set; }} function POSTMethodCall() {var Customer = {"CustomerDetails":{ "First_name": "My", "Last_name": "Test", "Mobile_No": "1234567890", "Email_ID": "[email protected]", "Address": "XYZ ABCD", "City": "ASDFGH", "Pincode": "400708"}};var st = JSON.stringify(Customer);debugger;$.ajax({type: "POST",url: "http://www.abc.co.in/Service1.svc/SaveUserData",Data: st,contentType: "application/json",dataType: "json",success: function (Data) {// Play with response returned in JSON format},error: function(Data){alert("Error:"+Data)}});