I have a .net 4.0 WCF servicing running with the following endpoint:
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "UploadReport")]
bool UploadReport(Report report);
My client is .net 2.0 and thus can't use [DataContract] on my objects. I'm using Json.net to serialize my data and then send it to the service.
string json = JsonConvert.SerializeObject(report);
WebRequest request = HttpWebRequest.Create("http://localhost:51605/QBDHandoffService.svc/UploadReport");
request.Method = "POST";
request.ContentType = "application/json";
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Close();
}
var response = (HttpWebResponse)request.GetResponse();
The call successfully reaches the service but the 'report' is always null. I suspect a serialization issue since I can't stick a [DataContract] on the object on the .net 2.0 side, but wasn't completely sure. The JSON looks good when I send it off, is there something I am missing here? How can I accomplish this? Thanks!