开发者

Accessing a webservice on android using webservice with complex data type using ksoap2

I am currently trying to write a webservice client using ksoap2.The webservice is returning the complex data type.I need to get that object using my webservice client.

开发者_开发问答

Please provide some pointers to achieve the same.


If the complex data type is hierarchy then create SoapObject until you get the last level. For example the following code snippet uses three SoapObjects to obtain the key and values of a soap response:

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);
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜