我正在尝试通过以下代码解析 Android 中的 SOAP:
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "";
private final String SOAP_ACTION = "http://tempuri.org/GetSeatLayout";
private final String METHOD_NAME = "GetSeatLayout";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
ArrayList<Object> strAreaCategoryCode = new ArrayList<Object>();
ArrayList<Object> intAreaNumber = new ArrayList<Object>();
ArrayList<Object> strClass = new ArrayList<Object>();
ArrayList<Object> objArrseatInfo = new ArrayList<Object>();
ArrayList<Object> intExceptioncode = new ArrayList<Object>();
ArrayList<Object> ScreenId = new ArrayList<Object>();
ArrayList<Object> StatusId = new ArrayList<Object>();
ArrayList<Object> TicketRate = new ArrayList<Object>();
ArrayList<Object> Charge = new ArrayList<Object>();
ArrayList<Object> OtherCharge = new ArrayList<Object>();
ArrayList<Object> TotalCharge = new ArrayList<Object>();
ArrayList<Object> strRow = new ArrayList<Object>();
ArrayList<Object> intSeat = new ArrayList<Object>();
ArrayList<Object> intSeatID = new ArrayList<Object>();
ArrayList<Object> rowseatStatus = new ArrayList<Object>();
ArrayList<Object> hasCurrentOrder = new ArrayList<Object>();
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
Log.e("","request"+request);
String strCinemaCode ="0002";
long lngSessionId=103286;
String strShowClass = "EXECUTIVE";
long lngNoOfTickets = 1;
int intBookId = 0;
long UniqueReqI = 0;
String SeatSelected = ",O_14";
int intAggregatorID = 1; //1-fame / 2-Inox
String strCTransId = "20002070519";
PropertyInfo strCinemaCode1 =new PropertyInfo();
strCinemaCode1.setName("strCinemaCode");
strCinemaCode1.setValue(strCinemaCode);
strCinemaCode1.setType(String.class);
request.addProperty(strCinemaCode1);
PropertyInfo lngSessionId1 =new PropertyInfo();
lngSessionId1.setName("lngSessionId");
lngSessionId1.setValue(lngSessionId);
//lngSessionId1.setType(long.class);
request.addProperty(lngSessionId1);
PropertyInfo strShowClass1 =new PropertyInfo();
strShowClass1.setName("strShowClass");
strShowClass1.setValue(strShowClass);
strShowClass1.setType(String.class);
request.addProperty(strShowClass1);
PropertyInfo lngNoOfTickets1 =new PropertyInfo();
lngNoOfTickets1.setName("lngNoOfTickets");
lngNoOfTickets1.setValue(lngNoOfTickets);
//lngNoOfTickets1.setType(long.class);
request.addProperty(lngNoOfTickets1);
PropertyInfo intBookId1 =new PropertyInfo();
intBookId1.setName("intBookId");
intBookId1.setValue(intBookId);
intBookId1.setType(Integer.class);
request.addProperty(intBookId1);
PropertyInfo UniqueReqI1 =new PropertyInfo();
UniqueReqI1.setName("UniqueReqI");
UniqueReqI1.setValue(UniqueReqI);
// UniqueReqI1.setType(long.class);
request.addProperty(UniqueReqI1);
PropertyInfo SeatSelected1 =new PropertyInfo();
SeatSelected1.setName("SeatSelected");
SeatSelected1.setValue(SeatSelected);
SeatSelected1.setType(String.class);
request.addProperty(strCinemaCode1);
PropertyInfo intAggregatorID1 =new PropertyInfo();
intAggregatorID1.setName("intAggregatorID");
intAggregatorID1.setValue(intAggregatorID);
intAggregatorID1.setType(Integer.class);
request.addProperty(intAggregatorID1);
PropertyInfo strCTransId1 =new PropertyInfo();
strCTransId1.setName("strCTransId");
strCTransId1.setValue(strCTransId);
strCTransId1.setType(String.class);
request.addProperty(strCTransId1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
//SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapObject response = (SoapObject)envelope.getResponse();
Log.e("","response:"+response.toString());
String []categories = new String [response.getPropertyCount()];
for (int i = 0; i < categories.length; i++) {
SoapObject pii = (SoapObject)response.getProperty(i);
strAreaCategoryCode.add(pii.getProperty(0));
Log.e(""," strAreaCategoryCode= "+ strAreaCategoryCode.get(i));
intAreaNumber.add(pii.getProperty(1));
Log.e(""," intAreaNumber= "+ intAreaNumber.get(i));
strClass.add(pii.getProperty(2));
Log.e(""," strClass= "+ strClass.get(i));
objArrseatInfo.add(pii.getProperty(3));
Log.e(""," objArrseatInfo= "+ objArrseatInfo.get(i));
intExceptioncode.add(pii.getProperty(4));
Log.e("","intExceptioncode= "+ intExceptioncode.get(i));
ScreenId.add(pii.getProperty(5));
Log.e("","ScreenId= "+ ScreenId.get(i));
StatusId.add(pii.getProperty(6));
Log.e(""," StatusId= "+ StatusId.get(i));
TicketRate.add(pii.getProperty(7));
Log.e(""," TicketRate= "+ TicketRate.get(i));
Charge.add(pii.getProperty(8));
Log.e(""," Charge= "+ Charge.get(i));
OtherCharge.add(pii.getProperty(9));
Log.e(""," OtherCharge= "+ OtherCharge.get(i));
TotalCharge.add(pii.getProperty(10));
Log.e(""," CinemaCode= "+ TotalCharge.get(i));
}
} catch (Exception e) {
Log.e("","Error In some connection");
String response = e.toString();
Log.e("",""+response);
}
}
}
通过使用上面的代码,我在日志表中得到以下响应
06-05 18:56:22.937: E/(1689): strAreaCategoryCode= 0000000007
06-05 18:56:22.937: E/(1689): intAreaNumber= 1
06-05 18:56:22.947: E/(1689): strClass= SILVER
06-05 18:56:23.027: E/(1689): objArrseatInfo= anyType{seatInfo=anyType{strRow=A; intRowID=1; intSeat=3; intSeatID=3; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=4; intSeatID=4; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=5; intSeatID=5; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=6; intSeatID=6; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=7; intSeatID=7; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=8; intSeatID=8; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=9; intSeatID=9; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=10; intSeatID=10; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=11; intSeatID=11; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=12; intSeatID=12; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=13; intSeatID=13; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=14; intSeatID=14; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=15; intSeatID=15; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=16; intSeatID=16; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=17; intSeatID=17; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=18; intSeatID=18; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=19; intSeatID=19; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=20; intSeatID=20; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=21; intSeatID=21; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=22; intSeatID=22; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=23; intSeatID=23; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=24; intSeatID=24; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=25; intSeatID=25; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=26; intSeatID=26; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=27; intSeatID=27; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=28; intSeatID=28; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=29; intSeatID=29; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=30; intSeatID=30; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=31; intSeatID=31; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=32; intSeatID=32; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=A; intRowID=1; intSeat=33; intSeatID=33; rowseatStatus=Sold; hasCurrentOrder=false; }; }
06-05 18:56:23.027: E/(1689): intExceptioncode= 0
06-05 18:56:23.038: E/(1689): ScreenId= 0
06-05 18:56:23.038: E/(1689): StatusId= 0
06-05 18:56:23.038: E/(1689): TicketRate= 0
06-05 18:56:23.038: E/(1689): Charge= 0
06-05 18:56:23.057: E/(1689): OtherCharge= 0
06-05 18:56:23.077: E/(1689): CinemaCode= 0
06-05 18:56:23.077: E/(1689): strAreaCategoryCode= 0000000007
06-05 18:56:23.088: E/(1689): intAreaNumber= 1
06-05 18:56:23.088: E/(1689): strClass= SILVER
06-05 18:56:23.227: E/(1689): objArrseatInfo= anyType{seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=4; intSeatID=4; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=5; intSeatID=5; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=6; intSeatID=6; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=7; intSeatID=7; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=8; intSeatID=8; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=11; intSeatID=11; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=12; intSeatID=12; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=13; intSeatID=13; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=14; intSeatID=14; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=15; intSeatID=15; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=16; intSeatID=16; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=17; intSeatID=17; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=18; intSeatID=18; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=19; intSeatID=19; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=20; intSeatID=20; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=21; intSeatID=21; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=22; intSeatID=22; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=23; intSeatID=23; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=24; intSeatID=24; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=25; intSeatID=25; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=28; intSeatID=28; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=29; intSeatID=29; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=30; intSeatID=30; rowseatStatus=Available; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=31; intSeatID=31; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intRowID=2; intSeat=32; intSeatID=32; rowseatStatus=Sold; hasCurrentOrder=false; }; seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; }; }
06-05 18:56:23.237: E/(1689): intExceptioncode= 0
06-05 18:56:23.249: E/(1689): ScreenId= 0
06-05 18:56:23.249: E/(1689): StatusId= 0
06-05 18:56:23.258: E/(1689): TicketRate= 0
06-05 18:56:23.258: E/(1689): Charge= 0
06-05 18:56:23.278: E/(1689): OtherCharge= 0
06-05 18:56:23.278: E/(1689): CinemaCode= 0
06-05 18:56:23.318: E/(1689): strAreaCategoryCode= 0000000007
06-05 18:56:23.318: E/(1689): intAreaNumber= 1
06-05 18:56:23.327: E/(1689): strClass= SILVER
等等..
现在查看响应变量 objArrseatInfo 也是一个数组,其中包含许多变量。
我试图将这些变量放入另一个变量但没有用。我怎样才能得到那些类似于主数组的变量?
例如
variable strAreaCategoryCode is getting value of pii.getProperty(0)
same way strRow should get the value of strRow from objArrseatInfo= anyType{seatInfo=anyType{strRow=B; intSeat=0; intSeatID=0; rowseatStatus=Available; hasCurrentOrder=false; };
我是 KSoap 库的新手,尝试后我无法解决这个问题。