SOAP - 非常大的XML响应 - 的OutOfMemoryError [英] SOAP - Very large XML response - OutOfMemoryError

查看:175
本文介绍了SOAP - 非常大的XML响应 - 的OutOfMemoryError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这个问题看起来像的<一个href="http://stackoverflow.com/questions/4941581/very-large-soap-response-android-out-of-memory-error/6925619#6925619">Very大型SOAP响应 - Android-内存不足的错误主题。因为我的英语的弱点而这个问题的相似性,以期便于理解一些语句段落被复制的。

我有一个应用程序,我需要通过SOAP调用一个web服务下载大量数据。该响应然后被发送到哪个显示XML文件的功能。

I have an application where i need to download a large amount of data via a SOAP call to a webservice. The response is then sent to a function which display the XML file.

数据超过11MB大小,我有一个的 java.lang.OutOfMemoryError 的每次。

The data is more than 11MB in size and i have a java.lang.OutOfMemoryError everytime.

修改web服务给予了少量的数据是不是一种选择。

Modifying the webservice to give out smaller amounts of data is not an option.

我用Http请求获得DATAS。我知道:我的resquest是好的,SOAPUI和Wireshark回报预期响应

I use "Http request" to get datas. I know that : my resquest is fine, soapUi and wireshark return expected responses.

但我的AVD无法通过此行

But my AVD isn't able to pass this line

的Htt presponse HTT presponse = httpClient.execute(httpPost);

工作的某些分钟后(在此期间,Wireshark的一些复苏预期的查询)是由这个错误

After some minutes of work (during which wireshark recovers some expected queries) this error is made

 Out of memory on a 16705124-byte allocation.

我试图SD卡尺寸升级到20GB,然而,错误依然。

I tried to upgrade the SD card size to 20GB, yet, error still.

解析HTT presponse可能是下一个步骤,是可以分析的Htt presponse同时由分裂成几个部分由exmple接收数据?

Parsing httpResponse is probably the next step, is it possible to parse HttpResponse while it receives data by fragmenting it into several parts by exmple?

你有一个想法?

谢谢, Dsandre

Thanks, Dsandre

推荐答案

感谢的格雷姆,打开连接为一个字节流的作品。如果它可以是有益的给别人,这是我的源$ C ​​$ C

Thank's Graeme, opening connection as a byte stream works. If it could be helpfull to somebody, this is my source code

        //Make a temporary file to save data
        File responseFile = File.createTempFile("SOAP", "xml", context.getFilesDir());      
        int nbCharRead = 0; int i=0; int totalRead = 0;

        //Send query
        OutputStream outputS = url_Connection.getOutputStream();
        Writer w_out = new OutputStreamWriter(outputS);
        w_out.write(webServiceXml);
        w_out.flush();
        w_out.close();


        //Buffers
        BufferedReader bufReader = new BufferedReader(new InputStreamReader(url_Connection.getInputStream()));
        BufferedWriter bufWriter = new BufferedWriter(new FileWriter(responseFile));
        char[] buffer = new char[10000];



        while((nbCharRead = bufReader.read(buffer, 0, 10000)) != -1)
        {
            totalRead += nbCharRead;
            Log.d("Test InputStream", "i: " + i++ +" - " + nbCharRead + " -> " + totalRead);
            bufWriter.write(buffer, 0, nbCharRead );
        }       

        if(bufWriter != null)
        {
            bufWriter.flush();
            bufWriter.close();
        }


        Log.w(MsgLog, "--- Stream Got--- ; Total : " + totalRead);

这篇关于SOAP - 非常大的XML响应 - 的OutOfMemoryError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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