webservice里面接受的请求字符串过长怎么解决
发黑的太阳 2018-07-25 11:07:11 string url = "http://localhost:7512/Service.asmx/WMS_OrderInfo?DATA" + text;
WebClient client = new WebClient();
//地址
//传的参数
//string path = "http://localhost:7512/Service.asmx/WMS_OrderInfo?DATA";
//数据较大的参数
string datastr = "=" + System.Web.HttpUtility.UrlEncode(text);
//参数转流
byte[] bytearray = Encoding.UTF8.GetBytes(datastr);
try
{
//采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//长度
client.Headers.Add("ContentLength", bytearray.Length.ToString());
Console.WriteLine(bytearray.Length.ToString());
//上传,post方式,并接收返回数据(这是同步,需要等待接收返回值)
byte[] responseData = client.UploadData(url, "POST", bytearray);
//释放
client.Dispose();
//处理返回数据(一般用json)
string srcString = Encoding.UTF8.GetString(responseData);
Console.WriteLine(srcString);