开发者

Partial xml response from web service via ksoap2

开发者 https://www.devze.com 2023-04-08 21:02 出处:网络
I\'m new in both Android and Java (use to develop in C# before) and I\'m quite desperate on this. I\'m using ksoap2 to contact a .NET Web Service to get xml data. My code is simple and it works well i

I'm new in both Android and Java (use to develop in C# before) and I'm quite desperate on this. I'm using ksoap2 to contact a .NET Web Service to get xml data. My code is simple and it works well if the xml is small:

soapEnvelope.setOutputSoapObject(request);
SoapPrimitive response = (SoapPrimitive) soapEnvelope.getResponse();
String xmlResponse = response.toString();

this is a simple way to get the response, which is a simple xml string. But when the xml is large, it gets truncate, and I suppose it is because the response is kept in memory. I read some other people having this problem, but I didn't find a solution that really helps me; probably I miss the necessary knowledge to manage the question, and this is confirmed by the fact that navigating the variables on Eclipse I found that the data is fully there, I only did't know how to reach it... can somebody help me? how can i get the miss开发者_开发百科ing part of the response? I need to save the response locally? Need to cycle an InputStream? help, please...


In debugger windows Eclipse will not show all the array elements. If you are able to see them all when you expand the array then they are all there for your program to use.

If you are suspecting large response, SAX is the right way to parse it

EDIT: As Manfred explains in this answer, response.toString() is a bad idea because KSoap has already done the parsing.


You should use the getResponse method of the envelope and parse the SoapObject tree for whatever you need. Using bodyIn and parsing that with SAX adds a second parsing.. if you do that you might as well not use ksoap2.

0

精彩评论

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

关注公众号