private List<AirLineInfo> getAirLine(String startCity, String lastCity, String theDate){
final String SERVICE_NS = "http://WebXml.com.cn/";
final String SERVICE_URL = "http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx";
String methodName = "getDomesticAirlinesTime";
HttpTransportSE httpTransport = new HttpTransportSE(SERVICE_URL);
httpTransport.debug = true;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);
soapObject.addProperty("startCity", startCity);
soapObject.addProperty("lastCity", lastCity);
soapObject.addProperty("theDate", theDate);
envelope.bodyOut = soapObject;
envelope.dotNet = true;
try {
httpTransport.call(SERVICE_NS + methodName, envelope);
if(envelope.getResponse() != null){
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(methodName + "Result");
SoapObject diffgram = (SoapObject) detail.getProperty("diffgram");
SoapObject airlines = (SoapObject) diffgram.getProperty("Airlines");
return SoapObjToList(airlines);
}
} catch (HttpResponseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
return null;
}
private List<AirLineInfo> SoapObjToList(SoapObject airlines){
List<AirLineInfo> airlineList = new ArrayList<AirLineInfo>();
for(int i = 0; i < airlines.getPropertyCount();i++){
SoapObject airline = (SoapObject) airlines.getProperty(i);
AirLineInfo airlineInfo = new AirLineInfo();
airlineInfo.setCompany(airline.getProperty("Company").toString());
airlineInfo.setStartDrome(airline.getProperty("StartDrome").toString());
airlineInfo.setArriveDrome(airline.getProperty("ArriveDrome").toString());
airlineInfo.setStartTime(airline.getProperty("StartTime").toString());
airlineInfo.setArriveTime(airline.getProperty("ArriveTime").toString());
airlineInfo.setAirlineCode(airline.getProperty("AirlineCode").toString());
airlineList.add(airlineInfo);
}
return airlineList;
}
WebService航班查询
最新推荐文章于 2019-01-08 01:21:11 发布