1
在Android中使用SOAP从Web服务获取单一数据并显示良好。但是当我需要从Web服务检索多组值时。我如何做到这一点? 。从一个webservice。,即时得到10个学生记录与字段stu.Name,stuRegno。,stuAge.After得到这个响应后,我需要解析它存储到本地数据库与相应的字段名称。我该怎么做那?在Android中使用SOAP从Web服务获取多个数据
我的代码:
public class Main extends Activity {
private static final String METHOD_NAME = "TopGoalScorers";
private static final String SOAP_ACTION = "http://footballpool.dataaccess.eu/data/TopGoalScorers";
private static final String NAMESPACE = "http://footballpool.dataaccess.eu";
private static final String URL = "http://footballpool.dataaccess.eu/data/info.wso?WSDL";
//Called when the activity is first created.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
//Buttons deaktiviert alles automatisch
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("iTopN", 3);// username von Preferences abgeholt
//request.addProperty("intB", 4);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
Toast.makeText(getApplicationContext(), request.toString(), Toast.LENGTH_LONG).show();
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
//Parse Response
SoapObject resultsRequestSOAP = (SoapObject) envelope.getResponse();
String xy = resultsRequestSOAP.getProperty(0).toString();
((TextView)findViewById(R.id.lblStatus)).setText(xy);
} catch(Exception E) {
((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
}
}
}