通过HttpClient请求webService
1、service:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl。查询的主要方法:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getMobileCodeInfo
2、可以看出该方法的两个传入参数的名称。
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();}}