View Full Version : Posting Json Dato to WCF Service

24 Dec 2010, 2:56 AM
i'm trying to post some json data from extjs to a WCF service:

this is the js code, it takes values from a FormPanel, encode to Json and call my wcf service. the encoded result is this:
{"RagSoc":"ANDREA MAI","Ind":"VIALE DELLA REPUBBLICA 45","Cap":"37026","Loc":"VERONA","Prov":"VR","IdPag":3,"PIva":"","CodFisc":"MAINDR79E08L781I","Tel":"3477418812","Fax":"","Email":"ANDREA@HSGROUP.NET","Dest":"","DestCap":"37026","DestInd":"VIA PAPA GIOVANNI PAOLO I, 5","DestLoc":"PESCANTINA","DestNazione":"IT","DestProv":"VR","IdAnag":"","IdCat":"3","Nazione":"IT","Riferimento":"","Url":""}

url: 'http://andrea-pc/GattoWebApp/AnagService.svc/SaveAnag',
method: 'POST',
headers: {'Content-Type':'text/json; charset=utf-8'},
jsonData: Ext.util.JSON.encode(formAnag.getValues())

this is the service contract

[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
void SaveAnag(Anag anag);

and the implementation:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class AnagService : IAnag
public void SaveAnag(Anag anag)

<enableWebScript /> is activated in the config file.

The ajax call send the json, but it's not parsed (anag is always null), besides i get no error, so what am i missing?