json 데이터를 포스트 방법으로 보내려면 webservice를 호출합니다. 여기에 대한 코드는 다음과 같습니다.설치 시간 웹 서비스 호출에 대한 메트릭
string sample_url = "mywebservice/createsample;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sample_url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.CookieContainer = new CookieContainer();
CookieCollection cookcol = new CookieCollection();
cookcol.Add(cookie);
string body= json data
byte[] postBytes = Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream postStream = request.GetRequestStream();
postStream.Write(postBytes, 0, postBytes.Length);
postStream.Close();
WebResponse response = request.GetResponse();
string satus = ((HttpWebResponse)response).StatusDescription;
postStream = response.GetResponseStream();
StreamReader reader = new StreamReader(postStream);
이 웹 서비스 요청 및 응답에 대한 시간 소인은 서비스가 상당히 느린 것처럼 보입니다. 이 주변에 카운트 다운 타이머를 두는 방법은 무엇입니까? 귀하의 회신에 감사드립니다.
Stopwatch sw = new Stopwatch();
sw.Start();
// your code to measure here
sw.Stop();
// print sw.Elapsed
감사 ............................ – fuller