1
我執行此代碼的數組:JavaNullPointer異常填充
HttpTransportSE transportSE = new HttpTransportSE(URL);
try{
//Web service call
transportSE.call(SOAP_ACTION_BRING_NEEDS, envelope);
//create SoapPrimitive and obtain response
resultsRequestSOAP = (SoapObject)envelope.getResponse();
int intPropertyCount = resultsRequestSOAP.getPropertyCount();
strNeeds = new String[intPropertyCount];
for(int i= 0;i< intPropertyCount; i++)
{
//strNeeds[i]= resultsRequestSOAP.getPropertyAsString(i).toString();
//Format the information from the web service
Object property = resultsRequestSOAP.getProperty(i);
if (property instanceof SoapObject) {
SoapObject needsList = (SoapObject) property;
strNeeds[i] = needsList.getProperty("Descripcion").toString();
strCodeNeeds[i] = needsList.getProperty("Codigo").toString();
}
}
}catch (Exception e){
exc = true;
e.printStackTrace();
}
及其對這行代碼制動:
strCodeNeeds[i] = needsList.getProperty("Codigo").toString();
,不同之處和suppressedExceptions = {[email protected]} = 0
上的錯誤java.lang.NullPointerException
。
我戴上「needList」迭代「對於」手錶,它包含這樣的結果在position 0 = anyType{Codigo=3; CodigoClase=1; Descripcion=Acceso a puerto; }
和陣列strNeeds[i]
被正確填充。
任何想法發生了什麼?謝謝你的建議。
做的需要sysList.getProperty(「Codigo」),看看你得到什麼。我的猜測是空的。 – Susie 2014-10-02 15:32:16
@Susie我這樣做,我得到正確的價值,我需要needsList.getProperty(「Codigo」)。toString()= {[email protected]}「3」 – Elsanty 2014-10-02 15:43:48
你在哪裏實例化'strCodeNeeds '? – 2014-10-02 16:05:00