首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android Base64+Soap+WebService 图片上传内存溢出有关问题

2013-11-11 
Android Base64+Soap+WebService 图片上传内存溢出问题public void testUpload(){try{String srcUrl /s

Android Base64+Soap+WebService 图片上传内存溢出问题


public void testUpload(){  
        try{  
            String srcUrl = "/sdcard/"; //路径  
            String fileName = "aa.jpg";  //文件名  
            FileInputStream fis = new FileInputStream(srcUrl + fileName);  
            ByteArrayOutputStream baos = new ByteArrayOutputStream();  
            byte[] buffer = new byte[1024];  
            int count = 0;  
            while((count = fis.read(buffer)) >= 0){  
                baos.write(buffer, 0, count);  
            }  
            String uploadBuffer = new String(Base64.encode(baos.toByteArray()));  //进行Base64编码  
            String methodName = "uploadImage";  
            connectWebService(methodName,fileName, uploadBuffer);   //调用webservice  
            Log.i("connectWebService", "start");  
            fis.close();  
        }catch(Exception e){  
            e.printStackTrace();  
        }  
    }  
 private boolean connectWebService(String methodName,String fileName, String imageBuffer) {  
        String namespace = "http://134.192.44.105:8080/SSH2/service/IService";  // 命名空间,即服务器端得接口,注:后缀没加 .wsdl,  
                                                                                //服务器端我是用x-fire实现webservice接口的  
        String url = "http://134.192.44.105:8080/SSH2/service/IService";   //对应的url   
        //以下就是 调用过程了,不明白的话 请看相关webservice文档     
        SoapObject soapObject = new SoapObject(namespace, methodName);      
        soapObject.addProperty("filename", fileName);  //参数1   图片名  
        soapObject.addProperty("image", imageBuffer);   //参数2  图片字符串  
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(  
                SoapEnvelope.VER10);  
        envelope.dotNet = false;  
        envelope.setOutputSoapObject(soapObject);  
        HttpTransportSE httpTranstation = new HttpTransportSE(url);  
        try {  
            httpTranstation.call(namespace, envelope); //这一步内存溢出 
            Object result = envelope.getResponse();  
            Log.i("connectWebService", result.toString());  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
        return false;  
    }  


[解决办法]
分块啊 没什么好办法 
 做个分块私有协议 
[解决办法]

引用:
分块啊 没什么好办法 
 做个分块私有协议


分块怎么做啊。。。?

热点排行