Using ksop2 how to send large files to web service
Asked Answered
S

4

6

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

Soutache answered 1/3, 2013 at 11:58 Comment(2)
Please post your code. Any answer to this question is just speculation unless we can actually see some code.Innumerable
Please Specify how much larger the files you are trying to send here, since if those file are larger than 4 mb then the problem is not in your android part its all in your web service part and you need to configure your web.Config file by setting the following attributes <httpRuntime maxRequestLength="Max_File_Size" executionTimeout="Max_Execution_Time" />.Violaviolable
H
1

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.

Hugibert answered 4/4, 2013 at 14:22 Comment(0)
B
0

Try to set your buffer to 1024 before sending it , its about the limit of your buffer size and your ram

Benz answered 6/4, 2013 at 2:59 Comment(0)
H
0

Use GZip Zipping algorithm to zip large file from mobile side; use same unzipping from server.

Also use MultipartEntity can help to upload large file content.

Helical answered 8/4, 2013 at 13:17 Comment(0)
A
0

If compression doesn't help - as mentioned in previous post - you will probably have to segment the message yourself.

Segmentation

Annamarieannamese answered 9/4, 2013 at 13:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.