/**
* 根據省份獲取城市列表
* @param province
* @return
*/
public static List<String> getCityListsByProvince(String province) {
// 調用的方法
String methodName = "getSupportCityString";
// 建立HttpTransportSE傳輸對象(信使)傳入服務器地址
HttpTransportSE ht = Ksoap2Helper.getHttpTransportSE(Ksoap2Configs.SERVICE_URL);
//建立soapObject對象並傳入命名空間和方法名--用來配置信封
SoapObject request = new SoapObject(Ksoap2Configs.SERVICE_NAMESPACE, methodName);
// 添加一個請求參數
request.addProperty("theRegionCode", province);
//初始化SoapSerializationEnvelope(信封)
SoapSerializationEnvelope envelope = Ksoap2Helper.getSoapSerializationEnvelope(request);
// 調用webservice
try {
ht.call(Ksoap2Configs.SERVICE_NAMESPACE + methodName, envelope);
if (envelope.getResponse() != null) {
// 獲取服務器響應返回的SOAP消息
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(methodName
+ "Result");
// 解析服務器響應的SOAP消息
return parseProvinceOrCity(detail);
}
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}web