asp.net - Trouble with ajax POST call to WCF service -
i calling wcf service ajax , can work request not post request. so:
[operationcontract] [webinvoke(method = "get", requestformat = webmessageformat.json, responseformat = webmessageformat.json)] public userobject getuser(string name) { // add operation implementation here var uo = new userobject() { custclass = "guest", fname = "chris", email = "chris@something", ismobile = false }; uo.fname = name; return uo; } and
var json = { "name": "test" }; $.ajax({ //get user name , 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 , customer class customerclass = data.d.custclass; ffname = data.d.fname; } }); works but:
[operationcontract] [webinvoke(method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json)] public userobject getuser(string name) { // add operation implementation here var uo = new userobject() { custclass = "guest", fname = "chris", email = "chris@something", ismobile = false }; uo.fname = name; return uo; } and
$.ajax({ //get user name , 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 , customer class customerclass = data.d.custclass; ffname = data.d.fname; } }); doesn't. missing simple? i'm tearing hair out here. thanks
use
bodystyle = webmessagebodystyle.wrappedrequest for webinvokeattribute
Comments
Post a Comment