【发布时间】:2014-10-02 15:19:30
【问题描述】:
我正在执行这段代码:
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();
异常错误java.lang.NullPointerException 和suppressedExceptions = {java.util.Collections$EmptyList@830033977576} = 0。
我将手表放在迭代“For”的“needList”上,它在position 0 = anyType{Codigo=3; CodigoClase=1; Descripcion=Acceso a puerto; }中包含此结果
并且数组strNeeds[i] 填充正确。
知道发生了什么吗?感谢您的建议。
【问题讨论】:
-
sysout of needsList.getProperty("Codigo") 看看你得到了什么。我猜它是空的。
-
@Susie 我这样做了,我得到了正确的值,我需要,needList.getProperty("Codigo").toString() = {java.lang.String@830038562832}"3"
-
你在哪里实例化了
strCodeNeeds? -
@yaa110 是的,教程中没有,但是代码很多,所以我后来才意识到。
标签: android arrays android-studio