c#用winform调用webservice模拟网页查询,获取的数据为空
RegexDatard=newRegexData();HttpClienthc=newHttpClient();publicstringgetinfo(stringcph...
RegexData rd = new RegexData();
HttpClient hc = new HttpClient();
public string getinfo(string cph,string fdjh,string yzm)
{
hc.Url = "http://www.tzga.gov.cn:6080/wscgs/vio.do?act=veh_vio_query";
hc.DefaultEncoding = System.Text.Encoding.Default;
hc.Verb = HttpVerb.POST;
hc.PostingData.Add("hphm", cph);
hc.PostingData.Add("hpzl", "02");//汽车类型
hc.PostingData.Add("fzjg", "浙");//车牌属地
hc.PostingData.Add("clsbdh", fdjh);//发动机号
hc.PostingData.Add("yzm", yzm);
string a = hc.GetString();
return a;
}
winform的调用
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = LoadImg("http://www.tzga.gov.cn:6080/wscgs/include/captcha_js.jsp");
}
调用
ServiceReference1.WebService1SoapClient a = new ServiceReference1.WebService1SoapClient();
content.Text = a.getinfo(cph.Text, fdjh.Text, yzm.Text); 展开
HttpClient hc = new HttpClient();
public string getinfo(string cph,string fdjh,string yzm)
{
hc.Url = "http://www.tzga.gov.cn:6080/wscgs/vio.do?act=veh_vio_query";
hc.DefaultEncoding = System.Text.Encoding.Default;
hc.Verb = HttpVerb.POST;
hc.PostingData.Add("hphm", cph);
hc.PostingData.Add("hpzl", "02");//汽车类型
hc.PostingData.Add("fzjg", "浙");//车牌属地
hc.PostingData.Add("clsbdh", fdjh);//发动机号
hc.PostingData.Add("yzm", yzm);
string a = hc.GetString();
return a;
}
winform的调用
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = LoadImg("http://www.tzga.gov.cn:6080/wscgs/include/captcha_js.jsp");
}
调用
ServiceReference1.WebService1SoapClient a = new ServiceReference1.WebService1SoapClient();
content.Text = a.getinfo(cph.Text, fdjh.Text, yzm.Text); 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询