0

我目前正在尝试使用 ksoap2 编写一个 Web 服务客户端。Web 服务正在返回复杂的数据类型。我需要使用我的 Web 服务客户端获取该对象。

请提供一些指示来实现相同的目标。

4

1 回答 1

0

如果复杂数据类型是层次结构,则创建 SoapObject 直到获得最后一层。例如,下面的代码片段使用三个 SoapObject 来获取一个肥皂响应的键和值:

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
        HttpTransportSE transport = new HttpTransportSE(URL);
        transport.debug = true;
        transport.call(SOAP_ACTION+"createSubmission", envelope);
        SoapObject so = (SoapObject) envelope.bodyIn;
        Log.i("data:SO", so.toString());
        SoapObject so2 = (SoapObject)so.getProperty(0);
        Log.i("data:SO2", so2.toString());
        int count = so.getPropertyCount();
        for(int i = 0; i < count; ++i) {
        SoapObject so3 = (SoapObject)so.getProperty(i);
        Log.i("data", (String)so3.getProperty(0)+" extra");
        String key = (String) so2.getProperty(0);
        Object val = so2.getProperty(1);
        data.put(key, val);
        }
于 2012-04-05T06:48:10.470 回答