Я хочу использовать информацию о широте долготы из XML-вывода веб-службы в приложении Android.Неполный xml при преобразовании объекта ksoap в xml
http://www.webservicex.net/airport.asmx?op=getAirportInformationByAirportCode
При проверке выходных данных в веб-браузере, я получаю следующее: Этот XML-файл не появляется, чтобы иметь какой-либо информации о стиле, связанный с ним. Дерево документов показано ниже.
<string xmlns="http://www.webserviceX.NET">
<NewDataSet> <Table> <AirportCode>MSP</AirportCode> <CityOrAirportName>MINNEAPOLIS INTL</CityOrAirportName> <Country>United States</Country> <CountryAbbrviation>US</CountryAbbrviation> <CountryCode>63</CountryCode> <GMTOffset>6</GMTOffset> <RunwayLengthFeet>10000</RunwayLengthFeet> <RunwayElevationFeet>841</RunwayElevationFeet> <LatitudeDegree>44</LatitudeDegree> <LatitudeMinute>54</LatitudeMinute> <LatitudeSecond>0</LatitudeSecond> <LatitudeNpeerS>N</LatitudeNpeerS> <LongitudeDegree>93</LongitudeDegree> <LongitudeMinute>13</LongitudeMinute> <LongitudeSeconds>0</LongitudeSeconds> <LongitudeEperW>W</LongitudeEperW> </Table> <Table> <AirportCode>MSP</AirportCode> <CityOrAirportName>MINNEAPOLIS INTL</CityOrAirportName> <Country>United States</Country> <CountryAbbrviation>US</CountryAbbrviation> <CountryCode>63</CountryCode> <GMTOffset>6</GMTOffset> <RunwayLengthFeet>10000</RunwayLengthFeet> <RunwayElevationFeet>841</RunwayElevationFeet> <LatitudeDegree>44</LatitudeDegree> <LatitudeMinute>54</LatitudeMinute> <LatitudeSecond>0</LatitudeSecond> <LatitudeNpeerS>N</LatitudeNpeerS> <LongitudeDegree>93</LongitudeDegree> <LongitudeMinute>13</LongitudeMinute> <LongitudeSeconds>0</LongitudeSeconds> <LongitudeEperW>W</LongitudeEperW> </Table> </NewDataSet>
</string>
Я получаю это в виде объекта SOAP в следующем коде:
private static String SOAP_ACTION = "http://www.webserviceX.NET/getAirportInformationByAirportCode";
private static String NAMESPACE = "http://www.webserviceX.NET";
private static String METHOD_NAME = "getAirportInformationByAirportCode";
private static String URL = "http://www.webservicex.NET/airport.asmx?WSDL";
public String source_textview, destination_textview;
//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//Use this to add parameters
request.addProperty("airportCode",airportCode);
//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
//androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
String result=androidHttpTransport.responseDump;
Log.d("xml:", "is:" + result);
}
catch (Exception e) {
e.printStackTrace();
}
Я получаю XML следующим образом:
D/xml:(4736): is:<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getAirportInformationByAirportCodeResponse xmlns="http://www.webserviceX.NET"><getAirportInformationByAirportCodeResult><NewDataSet /></getAirportInformationByAirportCodeResult></getAirportInformationByAirportCodeResponse></soap:Body></soap:Envelope>
Не беспокойтесь о предупреждающем сообщении о 'style information' - это только ваш браузер. Просмотрите исходный код или используйте инструменты разработчика, Fiddler и т. Д., Чтобы просмотреть фактический xml. Обратите внимание, однако, что сам webservice возвращает строку XmlEncoded - вам нужно будет декодировать ее до разбора латов и длин. – StuartLC
Меня не беспокоит предупреждение. Я хочу использовать объект Soap, о котором я упоминал, для извлечения информации lat-long – qoo