CallService
private string CallService(string url, string postData, string contentType)
{
try
{
HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(url);
byte[] data = System.Text.Encoding.UTF8.GetBytes(postData);
//string contentType = radioBtnJson.Checked ? "text/json" : "text/xml";
//contentType = "application/x-www-form-urlencoded";
httpWReq.Method = "POST";
httpWReq.ContentType = contentType + "; charset=utf-8";
httpWReq.ContentLength = data.Length;
using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString;
}
catch (Exception ex)
{
txtResult.Text += ex.ToString();
}
return null;
}