我用来从Web服务器接口下载XML字符串数据的代码如下:
public String getXMLStr() {
String XMLStr = FLAG_DATA_FAILED;
HttpTransportSE httpTransportSE = new HttpTransportSE(serviceURL, 10000);
httpTransportSE.debug = true;
SoapSerializationEnvelope serializationEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
SoapObject soapObject = new SoapObject(SERVICE_NS, methodName);
serializationEnvelope.bodyOut = soapObject;
try {
httpTransportSE
.call(SERVICE_NS + methodName, serializationEnvelope);
if (serializationEnvelope.getResponse() != null) {
SoapObject result = (SoapObject) serializationEnvelope.bodyIn;
XMLStr = result.getProperty(0).toString();
Log.i(TAG, "PropertyCount" + result.getPropertyCount());
}
} catch (IOException e) {
e.printStackTrace();
Log.i(TAG, "IOException----->" + e.toString());
// return null;
return FLAG_DATA_FAILED;
} catch (XmlPullParserException e) {
e.printStackTrace();
Log.i(TAG, "XmlPullParserException------>" + e.toString());
// return null;
return FLAG_XMLPARSER_ERROR;
}
// XMLStr= FLAG_DATA_FAILED;
return XMLStr;
}
我经常遇到的例外情况如下:
02-17 13:30:37.586: E/AndroidRuntime(30095): FATAL EXCEPTION: Thread-14147
02-17 13:30:37.586: E/AndroidRuntime(30095): java.lang.NullPointerException
02-17 13:30:37.586: E/AndroidRuntime(30095): at org.ksoap2.transport.ServiceConnectionSE.getResponseProperties(ServiceConnectionSE.java:85)
02-17 13:30:37.586: E/AndroidRuntime(30095): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:189)
02-17 13:30:37.586: E/AndroidRuntime(30095): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:114)
我想知道为什么????,谢谢