通过HttpClient请求webService

2025-04-07 11:58:36

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
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢