using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Net;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace WIDESEA_WMS
|
{
|
public class Request
|
{
|
/// <summary>
|
/// post请求
|
/// </summary>
|
/// <param name="postData">参数</param>
|
/// <param name="address">路径</param>
|
/// <returns></returns>
|
public static string RequestData(string postData, string url = "")
|
{
|
string reponse = string.Empty;
|
try
|
{
|
//string tmp = "";
|
//if (null != postData)
|
// tmp = JsonConvert.SerializeObject(postData);
|
byte[] param = Encoding.UTF8.GetBytes(postData);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
request.Method = "POST";
|
request.ContentType = "application/json";
|
request.GetRequestStream().Write(param, 0, param.Length);
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
{
|
Stream stream = response.GetResponseStream();
|
StreamReader streamReader = new StreamReader(stream);
|
string webResponse = streamReader.ReadToEnd();
|
reponse = webResponse;
|
}
|
}
|
catch (Exception ex)
|
{
|
reponse = ex.Message;
|
}
|
return reponse;
|
}
|
}
|
}
|