0

我正在尝试使用 Web 服务显示数据。代码没有给出错误,但是在按钮单击时,执行只发生在尝试部分,除此之外没有任何执行

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();
          }                         
        }
    });
4

1 回答 1

0

您正在调用的几种方法引发异常。

“跳过”代码表示抛出了异常。

在 catch 块中放一个 toast 以确认。

于 2013-02-09T11:48:30.227 回答