Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ksop2 how to send large files to web service

i have application that picks the file from a dedicated path on my device and sends it to server.

I m using ksoap2 lib to call .NET webservice to send my file to server. i am using Base 64 encoding.

I can send file with max size of 1MB without encryption and 850Kb with encryption. Encyrption algorithm i am using is 3DES.

If i try to send files larger than above size i get following error: Caused by: java.lang.OutOfMemoryError at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:121)

My Test environment: Android emulator with API Level 8, Android 2.2 and SDCard memory 512 MB

Is it that i am missing out something? Can using BLOB help me in this scenario

Is there any way to send larger file? i have heard of sending data chunks but have no idea on that . any link or sample code will really help.

to get file data using following code: here url = where file is stored

public byte[] getFileData( String vURL){ instream = new FileInputStream(vURL); size = (int) vURL.length();
fileContent = new byte[size]; instream.read(fileContent); }

Encode the data using following code:

byte[] res = Utilities.getFileData(file);
String mdata = android.util.Base64.encodeToString(res,                                android.util.Base64.DEFAULT);

calling server side web service and sending data to server

SoapObject request = new SoapObject(nameSpace, methodName);

if (fileData != null && !fileData.equals("")) {
      request.addProperty("vBLOBData", fileData);
}
   SoapSerializationEnvelope envelope = getEnvelope(request);
   HttpTransportSE ht = new HttpTransportSE(url); // ,3000
   ht.debug = true;
   ht.call(soapAction, envelope);
  response = (envelope.getResponse()).toString();

Not able to send filedata more than 1 MB.

Thanks in advance

like image 880
user1971799 Avatar asked Mar 01 '13 11:03

user1971799


1 Answers

I don't know what you are trying to achieve, but why you don't divide your file into parts and send each part individually into a loop or into an android background service using a timer that sends a part every x seconds.

like image 62
Yasmine GreenApple Avatar answered Oct 21 '22 15:10

Yasmine GreenApple