应该如何解析以下 ksoap Web 服务响应。(我是 android 中这部分的新手)。
这是从我的 ksop 对 Web 服务的响应中获得的响应。我在 android 4.1 设备上重新运行它。
<?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>
<GetNearestStationsResponse xmlns="http://tempuri.org/">
<GetNearestStationsResult>
<StationsCloseBy xmlns="">
<Station Station_id="332"
Station_Name="דוד המלך 30"
Eng_Station_Name="30 David Hamellech St."
Description="דוד המלך 30 מול הרבנות בשדרה"
Eng_Address="David ha-Melekh 30 opposite the Rabbinate"
Latitude="32.080000"
Longitude="34.785400"
DistanceFromStationInMeters="61"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="5"
NumOfAvailableDocks="15"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="331"
Station_Name="כיכר רבין"
Eng_Station_Name="Rabin Square"
Description="כיכר רבין מול אבן גבירול 76 -תחנה עירייה"
Eng_Address="Kikar Rabin, opposite Ibn Gabirol 76 - municipality station"
Latitude="32.081000"
Longitude="34.781100"
DistanceFromStationInMeters="360"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="12"
NumOfAvailableDocks="16"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="333"
Station_Name="ויצמן 15-איכילוב"
Eng_Station_Name="15 weizman st. Ichilov Hospital"
Description="ויצמן 15 איכילוב במדרכה מול בית החולים"
Eng_Address="Weizman 11 - Hospital"
Latitude="32.081100"
Longitude="34.788800"
DistanceFromStationInMeters="391"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="6"
NumOfAvailableDocks="14"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="345"
Station_Name="ויצמן 1 - בית המשפט"
Eng_Station_Name="1 Weizman St. - Court Justice Hall"
Description="ויצמן 1 בית המשפט"
Eng_Address="Weizman 1 - Court Justice Hall"
Latitude="32.077200"
Longitude="34.788400"
DistanceFromStationInMeters="476"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="4"
NumOfAvailableDocks="24"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="342"
Station_Name="שאול המלך 21 קאמרי"
Eng_Station_Name="21 Sauol Hamelekh- Hakameri"
Description="שאול המלך 21 קאמרי -במדרכה מימין למדרגות כניסה מערבית"
Eng_Address="Shaul ha-Melekh 21 Hakameri - on the sidewalk to the right of the west entrance stairs"
Latitude="32.075900"
Longitude="34.785100"
DistanceFromStationInMeters="478"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="8"
NumOfAvailableDocks="12"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="381"
Station_Name="פרישמן 77"
Eng_Station_Name="77 Frishman St."
Description="פרישמן 77-שדרות חן"
Eng_Address="77 Frishman St."
Latitude="32.079500"
Longitude="34.779700"
DistanceFromStationInMeters="488"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="10"
NumOfAvailableDocks="10"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="323"
Station_Name="תשח 2"
Eng_Station_Name="2 Tashah St."
Description="תשח 2 במדרכה"
Eng_Address="Tashakh 2 on the sidewalk"
Latitude="32.084700"
Longitude="34.786700"
DistanceFromStationInMeters="530"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="6"
NumOfAvailableDocks="14"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="324"
Station_Name="אבן גבירול 106 -בית הדואר"
Eng_Station_Name="106 Ibn Gvirol St. - Post Office"
Description="אבן גבירול 106 - בית הדואר במדרכה"
Eng_Address="Ibn Gabirol 106 - Post Office, on the sidewalk"
Latitude="32.084300"
Longitude="34.781600"
DistanceFromStationInMeters="546"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="9"
NumOfAvailableDocks="8"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="346"
Station_Name="אבן גבירול 28"
Eng_Station_Name="28 Ibn Gabirol St."
Description="אבן גבירול 28 לונדון מיניסטור מאחורי ספסל ארוך דרום לכניסה"
Eng_Address="Ibn Gabirol 28, London Ministore behind the long bench south of the entrance"
Latitude="32.075000"
Longitude="34.781800"
DistanceFromStationInMeters="642"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="12"
NumOfAvailableDocks="8"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
<Station Station_id="344"
Station_Name="נצח ישראל 4 פינת מסריק"
Eng_Station_Name="4 Netsakh Yisrael St./ Masaryk"
Description="נצח ישראל 4 פינת מסריק - תחנה בחניה בכביש "
Eng_Address="Netsakh Yisrael 4 corner of Masaryk - station at the roadside parking"
Latitude="32.077900"
Longitude="34.778300"
DistanceFromStationInMeters="665"
Timestamp="2013-01-30T11:05:03.320"
NumOfAvailableBikes="8"
NumOfAvailableDocks="12"
IsActive="1"
Station_picture=""
Station_Phone="*6070"
Telefax="" />
</StationsCloseBy>
</GetNearestStationsResult>
</GetNearestStationsResponse>
</soap:Body>
</soap:Envelope>
假设:envelope.bodyIn 是 Valid Note1 -
SoapObject response = (SoapObject) envelope.bodyIn;
int propertyCount = response.getPropertyCount();
String pro = response.getPropertyAsString(0);
Running the code above gives:
propertyCount=1
pro =
anyType{StationsCloseBy=anyType{Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; Station=anyType{}; }; }
Note2 - ksoap response was chopped (i have removed Additional Stations tags since it does not make any difference, it caontians same fields with different data)
Any help will be appreciated!
Thanks!