我正在使用KSoap在android中获取.net Web服务。我得到了输出,但我不知道如何将结果存储在Array ..我的代码看起来像
SoapObject request=new SoapObject(SOAP_NAMESPACE, METHOD_NAME);
request.addProperty("UId","212");
request.addProperty("verificationID","123456");
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
//Toast.makeText(this, "Request : "+request.getProperty(0), Toast.LENGTH_LONG).show();
HttpTransportSE httpTransport=new HttpTransportSE(SOAP_URL);
Log.v("Done", request.toString());
try {
httpTransport.call(SOAP_ACTION, envelope);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
SoapObject response = (SoapObject) envelope.getResponse();
Toast.makeText(this, "Detail : "+response.toString(), Toast.LENGTH_LONG).show();
Log.v("RESPONSE : ", response.toString());
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我在对象响应中获得了整个结果,但是不知道如何存储在数组中......如果有人知道请帮助我。
答案 0 :(得分:1)
List< SoapObject > results = ArrayList< SoapObject >();
... //your code here
results.add(response);
List是按链接存储对象,如数组。
答案 1 :(得分:0)
使用以下代码。
SoapObject response = (SoapObject) envelope.getResponse();
String ret[] = new String[response.getPropertyCount()];
for (int i = 0; i < response.getPropertyCount(); ++i) {
ret[i] = response.getProperty(i).toString();
}