首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从webservice获取安卓SoapObject中的所有数据

从webservice获取安卓SoapObject中的所有数据
EN

Stack Overflow用户
提问于 2016-01-31 16:34:06
回答 1查看 1.4K关注 0票数 0
代码语言:javascript
复制
    client = new SoapObject(NAMESPACE, METHOD_NAME);
    sse.setOutputSoapObject(client);
    sse.bodyOut = client;
    androidHttpTransport.call(SOAP_ACTION, sse);

    // This step: get file XML
    responseBody = (SoapObject) sse.getResponse();
    // remove information XML,only retrieved results that returned
    responseBody = (SoapObject) responseBody.getProperty(1);
    // get information XMl of tables that is returned
    table = (SoapObject) responseBody.getProperty(0);
    //Get information each row in table,0 is first row
    tableRow = (SoapObject) table.getProperty(0);
    setapp.appointment_no = tableRow.getProperty("appointmentno").toString();

问题是它只返回第一条记录并在textview中显示它,我想返回所有记录并在listView中显示它。

我想是因为这条线

代码语言:javascript
复制
tableRow = (SoapObject) table.getProperty(0);

我可以在列表中得到所有的结果吗?

这是我的布局文件

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/txt33"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        />


</LinearLayout>
EN

回答 1

Stack Overflow用户

发布于 2016-01-31 17:18:22

代码语言:javascript
复制
Following is the code block from my old project.
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
//add property
PropertyInfo pi=new PropertyInfo();
pi.setName("EmpName");
pi.setValue(Employee_ID);
pi.setType(String.class);
request.addProperty(pi);

//set the envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
        SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);


HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response=null;
try
{   
    //Give a call
    httpTransport.call(SOAP_ACTION, envelope);
    //Hold the the response
    response = envelope.getResponse();

    SoapObject result = (SoapObject) envelope.getResponse();
    SoapObject root = (SoapObject) result.getProperty(0);
    SoapObject emp = (SoapObject) root.getProperty("InfraWiseDetails");

    for (int i = 0; i < emp.getPropertyCount(); i++) {
        SoapObject emp1 = (SoapObject) emp.getProperty(i);
        String name = emp1.getProperty("EmpName").toString();
        String id = emp1.getProperty("Employee_ID").toString();

        //use String variables name and id as you wants
    }
}
catch (Exception exception)
{
    //exception
}

有关更详细的教程,请访问here

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35111864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档