|
|
|
@ -129,7 +129,43 @@ namespace DSWeb.Areas.Dispatch.Helper
|
|
|
|
|
return responseString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string DoPostHead(string url, Dictionary<string, string> headdic, string json)
|
|
|
|
|
{
|
|
|
|
|
string responseString = "";//post返回的结果
|
|
|
|
|
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, err) => { return true; };
|
|
|
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
|
|
|
|
|
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
|
|
|
|
|
req.Method = "POST";
|
|
|
|
|
if (headdic.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in headdic)
|
|
|
|
|
{
|
|
|
|
|
req.Headers.Add(item.Key, item.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(json))
|
|
|
|
|
{
|
|
|
|
|
byte[] postBytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
req.ContentType = "application/json; charset=utf-8";
|
|
|
|
|
req.ContentLength = Encoding.UTF8.GetByteCount(json);
|
|
|
|
|
Stream stream = req.GetRequestStream();
|
|
|
|
|
stream.Write(postBytes, 0, postBytes.Length);
|
|
|
|
|
req.Timeout = 100000;
|
|
|
|
|
stream.Close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
req.ContentLength = 0;
|
|
|
|
|
}
|
|
|
|
|
var response = req.GetResponse();
|
|
|
|
|
Stream streamResponse = response.GetResponseStream();
|
|
|
|
|
StreamReader streamRead = new StreamReader(streamResponse);
|
|
|
|
|
responseString = streamRead.ReadToEnd();
|
|
|
|
|
response.Close();
|
|
|
|
|
streamRead.Close();
|
|
|
|
|
|
|
|
|
|
return responseString;
|
|
|
|
|
}
|
|
|
|
|
public static string DoPost(string url, string json,string certificatepath,string password)
|
|
|
|
|
{
|
|
|
|
|
string responseString = "";//post返回的结果
|
|
|
|
|