public string getXmlStr(string hphmcode)
{
string Url = "http://localhost:8080/readvioinfo.jsp";
string hphm = hphmcode;
string hpzl = "02";
//Encoding encoding = Encoding.GetEncoding("utf-8");
Encoding encoding = Encoding.GetEncoding("GB2312");
string postData = "hphm=" + hphm + "&hpzl=" + hpzl;
byte[] data = encoding.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
//发送数据
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
//接收返回值
HttpWebResponse res = (HttpWebResponse)request.GetResponse();
StreamReader sReader = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
string strBack = sReader.ReadToEnd();
//Response.Write(strBack);
sReader.Close();
res.Close();
return strBack;
}
相关文章
- POST发送form-data格式请求多文件传递,接收实现,中文乱码以及文件名乱码解决
- Spring Boot程序 向其他API接口发送Http请求并接收返回结果
- socket 错误之:OSError: [WinError 10057] 由于套接字没有连接并且(当使用一个 sendto 调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。...
- java实现发送get/post请求并携带参数
- Java发送POST请求,参数为JSON格式,并接收返回JSON数据
- linux通过curl发送post请求,并携带header参数的命令
- RestTemplate 设置头信息,发送post请求,并携带参数(发短信)
- 使用HttpClient发送请求接收响应
- Java后台发送post请求,并接收返回信息
- vue axios 发送post请求,后端接收参数为null