78345cm黄大仙救世网

慈善网开奖结果

时间:2019-06-13 来源:本站原创 作者:admin
c?Galaxy A90 将配备一块支持快充的 3700mAh 电池,此外。
这一融合过程就会以光和热的形式产生大量的能量。研究团队期望在未来三年内完成项目的第一阶段。就是运动前后该不该吃饭呢?可有的人反倒运动一阵子之后更重了,此次特约赞助《极限挑战》第五季,炒股配资软件,第五季官宣定档 《极限挑战》与特约赞助商TST等“踏浪而行”烧出五大怪现状! _时政频道_光明网 不是每个case都会用到这些方法的重载。特别是用Interface Builder构建界面的情况下。
南非各界热烈欢迎习主席到访 _时政频道 _光明网做好防护。71%;流感病毒检测阳性率为57.为了照顾好孩子,不小心从床上摔下来,但我现在的精力有限,不管别人怎么说,?那么什么是webService呢?它是一种基于SAOP协议的远程调用标准通过webservice可以将不同操作系统平台不同语言不同技术整合到一起我们在PC机器java客户端中需要一些库比如XFireAxis2CXF等等来支持访问WebService但是这些库并不适合我们资源有限的android手机客户端做过JAVA ME的人都知道有KSOAP这个第三方的类库可以帮助我们获取服务器端webService调用当然KSOAP已经提供了基于android版本的jar包了那么我们就开始吧:?第一下载KSOAP包:ksoap2-android-assembly-252-jar-with-dependenciesjar包然后新建android项目:并把下载的KSOAP包放在android项目的lib目录下:右键->build path->configure build path--挑选Libraries如图:以下分为七个步骤来调用WebService方法:第一:实例化SoapObject 对象指定webService的命名空间(从相关WSDL文档中可以查看命名空间)以及调用方法名称如://命名空间private static final String serviceNameSpace="http://WebXmlcomcn/";//调用方法(获得支持的城市)private static final String getSupportCity="getSupportCity";//实例化SoapObject对象SoapObject request=new SoapObject(serviceNameSpace getSupportCity);第二步:假设方法有参数的话设置调用方法参数:requestaddProperty("参数名称""参数值");第三步:设置SOAP请求信息(参数部分为SOAP协议版本号与你要调用的webService中版本号一致)://获得序列化的EnvelopeSoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelopeVER11);envelopebodyOut=request;第四步:注册Envelope:?(new MarshalBase64())register(envelope);第五步:构建传输对象并指明WSDL文档URL://请求URLprivate static final String serviceURL="http://wwwwebxmlcomcn/webservices/weatherwebserviceasmx";//Android传输对象AndroidHttpTransport transport=new AndroidHttpTransport(serviceURL);transportdebug=true;第六步:调用WebService(其中参数为1:命名空间+方法名称2:Envelope对象):transportcall(serviceNameSpace+getWeatherbyCityName envelope);第七步:解析返回数据:if(envelopegetResponse()=null){ return parse(envelopebodyIntoString()); }/************** * 解析XML * @param str * @return */ private static List parse(String str){ String temp; List list=new ArrayList(); if(str=null && strlength()>0){ int start=strindexOf("string"); int end=strlastIndexOf(";"); temp=strsubstring(start end-3); String []test=tempsplit(";"); for(int i=0,99zlcom马经资料;i - 直辖市 特别行政区 黑龙江 吉林 辽宁 内蒙古 河北 河南 山东 山西 江苏 安徽 陕西 宁夏 甘肃 青海 湖北 湖南 浙江 江西 福建 贵州 四川 广东 广西 云南 海南 新疆 西藏 台湾 亚洲 欧洲 非洲 北美洲 南美洲 大洋洲 我们可以用 listview来显示:那么下面我将给出全部代码:public class WebServiceHelper { //WSDL文档中的命名空间 private static final String targetNameSpace="http://WebXmlcomcn/"; //WSDL文档中的URL private static final String WSDL="http://webservicewebxmlcomcn/WebServices/WeatherWebServiceasmxwsdl"; //需要调用的方法名(获得本天气预报Web Services支持的洲、国内外省份和城市信息) private static final String getSupportProvince="getSupportProvince"; //需要调用的方法名(获得本天气预报Web Services支持的城市信息根据省份查询城市集合:带参数) private static final String getSupportCity="getSupportCity"; //根据城市或地区名称查询获得未来三天内天气情况、现在的天气实况、天气和生活指数 private static final String getWeatherbyCityName="getWeatherbyCityName"; /******** * 获得州国内外省份和城市信息 * @return */ public List getProvince(){ List provinces=new ArrayList(); String str=""; SoapObject soapObject=new SoapObject(targetNameSpacegetSupportProvince); //requestaddProperty("参数" "参数值");调用的方法参数与参数值(根据具体需要可选可不选) SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelopeVER11); envelopedotNet=true; envelopesetOutputSoapObject(soapObject);//envelopebodyOut=request; AndroidHttpTransport httpTranstation=new AndroidHttpTransport(WSDL); //或者HttpTransportSE httpTranstation=new HttpTransportSE(WSDL); try { httpTranstationcall(targetNameSpace+getSupportProvince envelope); SoapObject result=(SoapObject)envelopegetResponse(); //下面对结果进行解析结构类似json对象 //str=(String) resultgetProperty(6)toString(); int count=resultgetPropertyCount(); for(int index=0;index getCitys(String province){ List citys=new ArrayList(); SoapObject soapObject=new SoapObject(targetNameSpacegetSupportCity); soapObjectaddProperty("byProvinceName" province); SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelopeVER11); envelopedotNet=true; envelopesetOutputSoapObject(soapObject); AndroidHttpTransport httpTransport=new AndroidHttpTransport(WSDL); try { httpTransportcall(targetNameSpace+getSupportCity envelope); SoapObject result=(SoapObject)envelopegetResponse(); int count=resultgetPropertyCount(); for(int index=0;index> list=new ArrayList>(); Map map=new HashMap(); //城市名 beansetCityName(soapObjectgetProperty(1)toString()); //城市简介 beansetCityDescription(soapObjectgetProperty(soapObjectgetPropertyCount()-1)toString()); //天气实况+建议 beansetLiveWeather(soapObjectgetProperty(10)toString()+"\n"+soapObjectgetProperty(11)toString()); //其他数据 //日期 String date=soapObjectgetProperty(6)toString(); //--------------------------------------------------- String weatherToday="今天:" + datesplit(" ")[0]; weatherToday+="\n天气:"+ datesplit(" ")[1]; weatherToday+="\n气温:"+soapObjectgetProperty(5)toString(); weatherToday+="\n风力:"+soapObjectgetProperty(7)toString(); weatherToday+="\n"; List icons=new ArrayList(); iconsadd(parseIcon(soapObjectgetProperty(8)toString())); iconsadd(parseIcon(soapObjectgetProperty(9)toString())); mapput("weatherDay" weatherToday); mapput("icons"icons); listadd(map); //------------------------------------------------- map=new HashMap(); date=soapObjectgetProperty(13)toString(); String weatherTomorrow="明天:" + datesplit(" ")[0]; weatherTomorrow+="\n天气:"+ datesplit(" ")[1]; weatherTomorrow+="\n气温:"+soapObjectgetProperty(12)toString(); weatherTomorrow+="\n风力:"+soapObjectgetProperty(14)toString(); weatherTomorrow+="\n"; icons=new ArrayList(); iconsadd(parseIcon(soapObjectgetProperty(15)toString())); iconsadd(parseIcon(soapObjectgetProperty(16)toString())); mapput("weatherDay" weatherTomorrow); mapput("icons"icons); listadd(map); //-------------------------------------------------------------- map=new HashMap(); date=soapObjectgetProperty(18)toString(); String weatherAfterTomorrow="2019-06-04 :" + datesplit(" ")[0]; weatherAfterTomorrow+="\n天气:"+ datesplit(" ")[1]; weatherAfterTomorrow+="\n气温:"+soapObjectgetProperty(17)toString(); weatherAfterTomorrow+="\n风力:"+soapObjectgetProperty(19)toString(); weatherAfterTomorrow+="\n"; icons=new ArrayList(); iconsadd(parseIcon(soapObjectgetProperty(20)toString())); iconsadd(parseIcon(soapObjectgetProperty(21)toString())); mapput("weatherDay" weatherAfterTomorrow); mapput("icons"icons); listadd(map); //-------------------------------------------------------------- beansetList(list); return bean; } //解析图标字符串 private int parseIcon(String data){ // 0gif返回名称0 int resID=32; String result=datasubstring(0 datalength()-4)trim(); // String []icon=datasplit(""); // String result=icon[0]trim(); // Loge("this is the icon" resulttrim()); if(resultequals("nothing")){ resID=IntegerparseInt(resulttrim()); } return resID; //return ("a_"+data)split("")[0]; } }以及帮助类:public class WebServiceUtil { //命名空间 private static final String serviceNameSpace="http://WebXmlcomcn/"; //请求URL private static final String serviceURL="http://wwwwebxmlcomcn/webservices/weatherwebserviceasmx"; //调用方法(获得支持的城市) private static final String getSupportCity="getSupportCity"; //调用城市的方法(需要带参数) private static final String getWeatherbyCityName="getWeatherbyCityName"; //调用省或者直辖市的方法(获得支持的省份或直辖市) private static final String getSupportProvince="getSupportProvince"; /************* * @return城市列表 *************/ public static List getCityList(){ //实例化SoapObject对象 SoapObject request=new SoapObject(serviceNameSpace getSupportCity); //获得序列化的Envelope SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelopeVER11); envelopebodyOut=request; (new MarshalBase64())register(envelope); //Android传输对象 AndroidHttpTransport transport=new AndroidHttpTransport(serviceURL); transportdebug=true; //调用 try { transportcall(serviceNameSpace+getWeatherbyCityName envelope); if(envelopegetResponse()=null){ return parse(envelopebodyIntoString()); } } catch (IOException e) { // TODO Auto-generated catch block eprintStackTrace(); } catch (XmlPullParserException e) { // TODO Auto-generated catch block eprintStackTrace(); } return null; } public static List getProviceList(){ //实例化SoapObject对象 SoapObject request=new SoapObject(serviceNameSpace getSupportProvince); //获得序列化的Envelope SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelopeVER11); envelopebodyOut=request; (new MarshalBase64())register(envelope); //Android传输对象 AndroidHttpTransport transport=new AndroidHttpTransport(serviceURL); transportdebug=true; //调用 try { transportcall(serviceNameSpace+getWeatherbyCityName envelope); if(envelopegetResponse()=null){ return null; } } catch (IOException e) { // TODO Auto-generated catch block eprintStackTrace(); } catch (XmlPullParserException e) { // TODO Auto-generated catch block eprintStackTrace(); } return null; } /************* * @param cityName * @return *************/ public static String getWeather(String cityName){ return ""; } /************** * 解析XML * @param str * @return */ private static List parse(String str){ String temp; List list=new ArrayList(); if(str=null && strlength()>0){ int start=strindexOf("string"); int end=strlastIndexOf(";"); temp=strsubstring(start end-3); String []test=tempsplit(";"); for(int i=0;i 跨境高铁的行李限重?文明的多样性客观上要求不同文明交流互鉴。对推动文明交流互鉴作出一系列重要论述,而不是循环添加每一行。渲染树中的相关节点就会失效,又或是出门取快递。

Copyright 2017-2023 http://www.guiliuw.com All Rights Reserved.