获取KSOAP对象从HttpTransportSE.responseDump [英] Getting ksoap object from HttpTransportSE.responseDump

查看:173
本文介绍了获取KSOAP对象从HttpTransportSE.responseDump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无能如何进一步进行转换时 transport.responseDump 它返回的字符串(XML数据以字符串形式),以KSOAP对象。
可能有些code片段将帮助我在描述我的问题:

I am clueless how to proceed further while converting transport.responseDump which returns string(xml data in string form) to ksoap object. May be some code snippet will help me in describing my problem:

synchronized (transportLockObject)
        {
            transport.debug = true;            
            String soapAction = TARGET_NAMESPACE+"/"+method;

            try {
                transport.call(soapAction, envelope);
            } catch (SSLHandshakeException she) {
                she.printStackTrace();          
            }
        }
         System.out.println("Response ----------"+transport.responseDump);

这是我如何得到responseDump。我保存此转储,以便它可以在以后使用(说的时候,我不想实际在线数据用于测试目的或无连接[任何的])。
后来什么通常我要做的就是

This is how I am getting the responseDump. I am saving this dump so that it can be used later (say when I don't want actual online data for testing purpose or no connection[whatever]). Later what normally I do is

        Object response = envelope.getResponse();

        //Check if response is available... if yes parse the response
        if (response != null)
        {
            if (myResponse != null)
            {
                myResponse.parse(response);
            }
        }

这是我在解析通过()这个反应实际上是一个SOAP对象。 任何机构可以告诉我怎么能转换transport.responseDump返回我的价值为SOAP对象,这样我可以将它传递到parse()方法?

任何线索或链接会有所帮助。任何帮助将AP preciated。

Any clue or link will be helpful. any help will be appreciated.

推荐答案

您可以使用,而不是'GETRESPONSE

You can use "bodyIn" instead of 'getResponse'

httpTransport.call(SOAP_ACTION, soapEnvelope);

使用

SoapObject result = (SoapObject) soapEnvelope.bodyIn;
UserDefined resultVariable = new UserDefined(j);

的用户定义的构造应该能够处理这种情况。

The UserDefined constructor should be able to handle this.

如果您的预期目标是用户定义的对象,你应该实现与kvmserializable。你可以在这里找到一些例子。

If your expected object is a user defined object you should implement that with kvmserializable. you can find some example here.

<一个href=\"http://stackoverflow.com/questions/10999763/ksoap2-and-kvmserializable-how-to-send-complex-objects-like-stringarrays\">KSoap2和KvmSerializable - 如何发送像Stringarrays 复杂的对象

这篇关于获取KSOAP对象从HttpTransportSE.responseDump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆