使用 ksoap2 使用具有复杂数据类型的 Web 服务访问 Android 上的 Web 服务

发布于 2024-11-29 17:09:36 字数 141 浏览 1 评论 0原文

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

Please provide some pointers to achieve the same.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情域 2024-12-06 17:09:36

如果复杂数据类型是层次结构,则创建 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);
        }

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);
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文