好的,这是我的问题:
我正在发送一个soap-Request,我得到一个有效的答案,一切正常,我在responsedump中得到了有效的输出。 但是在:
中调用evelope.getResponse()SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//adding parameters
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.setAddAdornments(false);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject so = (SoapObject) envelope.getResponse();
抛出此异常:
Caused by: java.lang.NullPointerException
at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:521)
错误在getResponse中 来自ksoap2的来源:
/ ** *来自肥皂电话的回复。从包装器对象中拉出对象并返回它。 * * @since 2.0.3 * @return响应来自soap调用。 * @throws SoapFault * /
public Object getResponse() throws SoapFault {
if (bodyIn instanceof SoapFault) {
throw (SoapFault) bodyIn;
}
KvmSerializable ks = (KvmSerializable) bodyIn; <-- Line 521
if (ks.getPropertyCount()==0) {
return null;
} else if(ks.getPropertyCount()==1) {
return ks.getProperty(0);
} else {
Vector ret = new Vector();
for(int i=0;i<ks.getPropertyCount();i++){
ret.add(ks.getProperty(i));
}
return ret;
}
}
答案 0 :(得分:1)
试试这个而不是SoapObject
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();