1个回答
展开全部
string strPara = "para1=1¶2=2";
HttpWebRequest request1 = (HttpWebRequest)HttpWebRequest.Create("http://127.0.0.1/services/test?wsdl/test");
request1.Method = "POST";
request1.ContentType = "application/x-www-form-urlencoded";
request1.Timeout = 10000;
byte[] data = Encoding.UTF8.GetBytes(strPara);//参数
request1.ContentLength = data.Length;
Stream writer1 = request1.GetRequestStream();
writer1.Write(data, 0, data.Length);
writer1.Close();
WebResponse response = request1.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
strResponse = sr.ReadToEnd();
sr.Close();
HttpWebRequest request1 = (HttpWebRequest)HttpWebRequest.Create("http://127.0.0.1/services/test?wsdl/test");
request1.Method = "POST";
request1.ContentType = "application/x-www-form-urlencoded";
request1.Timeout = 10000;
byte[] data = Encoding.UTF8.GetBytes(strPara);//参数
request1.ContentLength = data.Length;
Stream writer1 = request1.GetRequestStream();
writer1.Write(data, 0, data.Length);
writer1.Close();
WebResponse response = request1.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
strResponse = sr.ReadToEnd();
sr.Close();
更多追问追答
追问
这个方法你有用过吗?
追答
恩 这个是POST传参,如果GET方式就更简单点。我自己在用的的方法,里面的参数根据自己情况改。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询