2013-02-09 109 views
0

我想顯示數據使用Web服務。該代碼沒有給出錯誤,但按鈕點擊執行發生最多隻能嘗試的一部分,沒有什麼超出了是執行沒有錯誤,但沒有執行後嘗試catch語句

try { 
       Toast.makeText(getApplicationContext(), "You r in try", Toast.LENGTH_LONG).show(); 
       HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
       //this is the actual part that will call the webservice 
       androidHttpTransport.call(SOAP_ACTION1, envelope);     
       // Get the SoapResult from the envelope body. 
       SoapObject result = (SoapObject)envelope.bodyIn; 
       //from here nothing executes but gives no error 
       ****if(result != null**) 
       { 
        Toast.makeText(getApplicationContext(), "You r in if", Toast.LENGTH_LONG).show(); 
         //Get the first property and change the label text 
         tv1.setText(result.getProperty(0).toString());  
       } 
       else 
       { 
         Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show(); 
       } 
      } catch (Exception e) { 
       e.printStackTrace(); 
      }       
     } 
    }); 
+0

您是否嘗試過烘烤結果?您是如何得到 – Payal 2013-02-09 11:13:44

+1

清潔您的項目,然後再試一次。也不用烤麪包。使用Log.i(「TAG」,「Your message」); – 2013-02-09 11:14:34

+0

爲什麼不調試應用程序並在有問題的區域放置斷點? – 2013-02-09 12:07:12

回答

0

你調用拋出異常的幾種方法。

「跳過」代碼表示拋出了異常。

在catch塊中放置麪包以確認。

+0

androidHttpTransport.call(SOAP_ACTION1,envelope);這行代碼沒有被執行休息,我通過放置烤麪包來檢查。 – 2013-02-11 10:16:36

+0

我有一個更具體的問題:如果你在catch塊中放了一個烤麪包,你會看到烤麪包嗎?如果你這樣做,那麼拋出異常。 – chr 2013-02-12 01:03:25