赞
踩
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); string param = BuildParamGetPatientInfoForSDEY(inHospitalID, caseNum); logInfo.LogStepDetail(cCfg, "请求的JSON内容:", param); Encoding encoding = Encoding.UTF8; byte[] byteArray = Encoding.UTF8.GetBytes(param); req.Method = "POST"; req.Headers.Add("access_token", token); req.ContentType = "application/json"; req.ContentLength = byteArray.Length; req.Accept = "*/*"; req.Timeout = 30 * 1000; req.ReadWriteTimeout = 30 * 1000; req.ServicePoint.Expect100Continue = false; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(byteArray, 0, byteArray.Length); } using (HttpWebResponse response = (HttpWebResponse)req.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding)) { responseDate = reader.ReadToEnd(); logInfo.LogStepDetail(cCfg, "POST请求的返回结果", responseDate); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。