I have a big problem when I try to send big amount of data to web service. I need to send about 20-30 photos to web service. I convert all photo to base64 strings and send to web service. The problem is that when I send 1 photo is ok, but when I try to send 2 photo or more I have out of memory exception. My code:
public boolean TransferAccidentFromGisToRarParameters(List<String> photos) {
String METHOD_NAME = "TransferAccidentFromGisToRarParameters";
String SOAP_ACTION = NAMESPACE + METHOD_NAME;
request = new SoapObject(NAMESPACE, METHOD_NAME);
envelope.setOutputSoapObject(request);
SoapObject arr = new SoapObject(NAMESPACE, "accidentPhotos");
for (String string : photos) {
arr.addProperty("string", string);
}
request.addSoapObject(arr);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
return Boolean.parseBoolean(response.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
Where: photos - a list of base64 strings My web service code block(asmx web service):
[WebMethod]
public bool TransferAccidentFromGisToRarParameters(string[] accidentPhotos)
{
try
{
foreach (var photo in accidentPhotos)
{
var item = Convert.FromBase64String(photo);
var accidentMedia = new AccidentMedia { Content = item };
entities.media_accidents.AddObject(accidentMedia);
}
entities.SaveChanges();
return true;
}
catch (Exception exc)
{
return false;
}
}
This is exceptions in Android log:
I'll be glad for your answers. Best regards!