700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 通过Webservice查询手机号码归属地

通过Webservice查询手机号码归属地

时间:2019-04-20 09:45:00

相关推荐

通过Webservice查询手机号码归属地

独角兽企业重金招聘Python工程师标准>>>

publicclassSearchLocationTaskextendsAsyncTask{privateStringmethodName;privateStringsoapAction;privateStringphoneNum;privateStringgetPropertyName;publicSearchLocationTask(StringphoneNum){this.methodName=Constant.GET_LOCATION_METHOD_NAME;this.soapAction=Constant.GET_LOCATION_SOAP_ACTION;this.phoneNum=phoneNum;this.getPropertyName=Constant.GET_LOCATION_RESULT_NAME;}@OverrideprotectedObjectdoInBackground(Object...params){//TODOAuto-generatedmethodstubSoapObjectdetail=null;Objectresult=null;try{SoapObjectrpc=newSoapObject(Constant.NAMESPACE,methodName);rpc.addProperty("mobileCode",phoneNum);Looper.prepare();HttpTransportSEht=newHttpTransportSE(Constant.URL);ht.debug=true;SoapSerializationEnvelopeenvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);envelope.bodyOut=rpc;envelope.dotNet=true;envelope.setOutputSoapObject(rpc);ht.call(soapAction,envelope);detail=(SoapObject)envelope.bodyIn;result=detail.getProperty(getPropertyName);}catch(Exceptione){e.printStackTrace();}returnresult;}@OverrideprotectedvoidonPostExecute(Objectresult){//TODOAuto-generatedmethodstubsuper.onPostExecute(result);/***解析数据*/StringresultStr=result.toString();String[]resultList=resultStr.split("");if(resultList.length==1){//获取字符串汇中的中文列表Util.showMessageByToast(currentContext,resultList[0]);}else{//获取省份名Stringprovince=Constant.GetChineseWord(resultList[0]).get(0);//获取城市名Stringcity=resultList[1];intlength=province.length()+2;//获取运营商Stringservice=resultList[2].substring(0,length);//获取卡类型StringcardType=resultList[2].substring(length);//展示//......}}}

publicclassConstant{/***命名空间*/publicstaticfinalStringNAMESPACE="/";/***获取归属地信息URL*/publicstaticStringURL="/webservices/MobileCodeWS.asmx";/***获得归属地方法名*/publicstaticStringGET_LOCATION_METHOD_NAME="getMobileCodeInfo";/***获得归属地soapAction*/publicstaticStringGET_LOCATION_SOAP_ACTION="/getMobileCodeInfo";/***获取归属地返回数据key*/publicstaticStringGET_LOCATION_RESULT_NAME="getMobileCodeInfoResult";/***获取字符串中的中文列表*@paramoriText*@return*/publicstaticList<String>GetChineseWord(Stringstr_text){List<String>chineseWordsList=newArrayList<String>();Stringreg="([\u4e00-\u9fa5]+)";Matchermatcher=pile(reg).matcher(str_text);while(matcher.find()){chineseWordsList.add(matcher.group());}returnchineseWordsList;}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。