Here is my service method signature:
[OperationContract]
[System.ServiceModel.Web.WebInvoke(UriTemplate = "/RegisterUser", Method = "POST")]
void RegisterNewUser(User user);
Also Type User have DataContract attribute on class and DataMember attributes on its properties
and here is how I am calling the service method:
String data = "{\"user\":{\"__type\" : \"User:#PingMe\",\"EmailID\": \"[email protected]\",\"RegistrationID\": \"sdfhjklsdgkdfjgklgdjfklg\"}}";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:2443/NotificationService.svc/RegisterUser");
httpWebRequest.Method = "POST";
byte[] bytes = Encoding.UTF8.GetBytes(data);
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.ContentType = "text/json; charset=utf-8";
httpWebRequest.KeepAlive = false;
Stream requestStream = httpWebRequest.GetRequestStream();
requestStream.Write(bytes,0,bytes.Length);
requestStream.Close();
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
It call the service method succesfully, but in service method's user parameter user.EmailID and User.RegistrationID always come 'NULL'
Any Idea what I am missing here?
Do I need to set RequestFormat property as WebMessageFormat.JSON? in OperationContract attribute?
Thanks