网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

通过HttpClient请求webService

时间:2024-11-12 02:53:38

1、service:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl。查询的主要方法:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getMobileCodeInfo

通过HttpClient请求webService

2、可以看出该方法的两个传入参数的名称。

通过HttpClient请求webService

3、下面直接上代码[java觥终柯计]view plaincopyprivatevoidgetMobileCodeInfo(){try{finalStringSERVER_URL="http多唉捋胝://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo";//定义需要获取的内容来源地址HttpPostrequest=newHttpPost(SERVER_URL);List<BasicNameValuePair>params=newArrayList();params.add(newBasicNameValuePair("mobileCode","136370628"));//(注意这里的号码必须大于6位)params.add(newBasicNameValuePair("userId",""));request.setEntity(newUrlEncodedFormEntity(params,HTTP.UTF_8));HttpResponsehttpResponse=newDefaultHttpClient().execute(request);if(httpResponse.getStatusLine().getStatusCode()!=404){Stringresult=EntityUtils.toString(httpResponse.getEntity());System.out.println(result);}}catch(Exceptione){Log.e("eee",""+e);e.printStackTrace();}}

通过HttpClient请求webService
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com