使用上面的代码我可以下载一些数据,比如'Limit = 5/10',但是当我尝试下载'Limit = 50'时,它会给我以下错误:
> 10-02 06:44:28.075: E/AndroidRuntime(27598): FATAL EXCEPTION:
> pool-1-thread-1 10-02 06:44:28.075: E/AndroidRuntime(27598):
> java.lang.OutOfMemoryError 10-02 06:44:28.075:
> E/AndroidRuntime(27598): at
> java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:124)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> java.lang.StringBuilder.append(StringBuilder.java:271) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1338) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> org.kxml2.io.KXmlParser.next(KXmlParser.java:390) 10-02 06:44:28.075:
> E/AndroidRuntime(27598): at
> org.kxml2.io.KXmlParser.next(KXmlParser.java:310) 10-02 06:44:28.075:
> E/AndroidRuntime(27598): at
> org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2056) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.serialization.DM.readInstance(DM.java:35) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:428)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:387)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:151)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.transport.Transport.parseResponse(Transport.java:118) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:253)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> com.example.inforlider.SyncActivity$4.run(SyncActivity.java:189) 10-02
> 06:44:28.075: E/AndroidRuntime(27598): at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
> 10-02 06:44:28.075: E/AndroidRuntime(27598): at
> java.lang.Thread.run(Thread.java:841)
可能其中一个问题可能是由于字段“Image”,因为它是一个BLOB并返回一个非常大的字符串?
我该怎么办?感谢。
答案 0 :(得分:0)
获取并将soap xml保存到手机存储空间,然后解析它。当xml存储在内存中时,不应该解析它。
你可以参考:How to download XML file from server and save it in SD card?
答案 1 :(得分:0)
我通过不包括字段“Image”解决了这个问题,因为它是函数中的BLOB(大数据)。之前,我创建了另一个函数,只读取“Image”字段。