2011-08-17 71 views

回答

0

如果複雜數據類型是層次結構,那麼創建SoapObject直到獲得最後一個層次。例如,以下代碼片段使用三個SoapObjects獲取肥皂響應的鍵和值:

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     HttpTransportSE transport = new HttpTransportSE(URL); 
     transport.debug = true; 
     transport.call(SOAP_ACTION+"createSubmission", envelope); 
     SoapObject so = (SoapObject) envelope.bodyIn; 
     Log.i("data:SO", so.toString()); 
     SoapObject so2 = (SoapObject)so.getProperty(0); 
     Log.i("data:SO2", so2.toString()); 
     int count = so.getPropertyCount(); 
     for(int i = 0; i < count; ++i) { 
     SoapObject so3 = (SoapObject)so.getProperty(i); 
     Log.i("data", (String)so3.getProperty(0)+" extra"); 
     String key = (String) so2.getProperty(0); 
     Object val = so2.getProperty(1); 
     data.put(key, val); 
     } 
相關問題