I am using Soap API (asmx) as web service for my project and I need to send a POST request with JSON data. I saw a code snippet that shows how to send the POST request using HttpWebRequest. This is the code.
string url = "http://myserver.rocket.com.my/WebService1.asmx/AddCompany";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = JsonConvert.SerializeObject(company);
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
My problem is, I am not very sure how to handle the request on server side. Can get any example or guide on how to obtain the json content from the stream?