Efficient way of sending data to web service - android

I have web Service on .net . And i use to upload data to this web service at regular interval of time . My data contains mostly string and some byte[] of Image (Around 8 of them). It takes around 4-5 mins to upload .
Now my problem is while sending data via GPRS (Android Mobile ) and it take lot of time to upload data (sometime connection time out also occurs), Can any one tell me how to improve upload time .
I am using KSOAP2 for sending data .

There are some possible techniques for reducing the data to be transfered - however all of them require special server features or if not supported changes on server side:
The simplest way would be to use HTTP transport compression but that is a feature that has to be supported by the server.
An alternative that reduces the XML overhead would be to switch to WBXML (binary encoded xml - once developed for "WAP") but AFAIK KSoap does not support it (and most web-service servers, too)

Related

send image data from android device to web-server

I'm developing a server-client web based application. Clients are mobile phones (android) which should send their data to the server. Their data includes (among other things) images which may be up to 1MB in size. What is the best way for sending these images to the server? A web service? FTP? or something else? Provided we have fast and stable mobile internet connection, can we safely use web service? I can imagine that android device sends image data as raw binary to the webservice and webservice writes these data into database, then website can use these data to display images. Is it a good idea to use webservice for this scenario (specially for large images being up to 1MB in size)? or I should other methods?

Can I use both REST and SOAP in an Android application?

I am trying to build an Android application.
It has a SOAP-based Web service from which it needs to consume the data.
I have a middle-ware Worklight server implementation too.
The data coming from the Web Service is huge and is actually all the data is not needed all the time. I was planning that I would use the middleware Worklight server to consume the SOAP web service, rather than the Android app itself, parse the data and then expose the required bits as a RESTful service and the data format JSON rather than SOAP XML format.
I think that this will take the load of parsing the huge XML data off the app. Is this a good approach?
I see no problem with your overall design, i.e. consuming the large chunk of data from the SOAP call in your middleware server and then only exposing the specific things you need for your Android clients.
It will at least save you bandwidth on your Android devices (which is a really good thing) and most likely a few lines of code in your Android project since your REST data will be tailored for your specific use-cases.
JSON or XML? What better fits your needs.
I'd advice you to look at versioning your REST services though. This is a good start: Best practices for API versioning?

Accessing database or webservice

I want to access an online MySQL database in order to retrieve and manipulate data. I read that the best way would be implementing an own web-service, which returns XML and then parse it in Android, is it right?
Does anybody have a basic tutorial?
Since you want to access a remote server which has your DB and other stuff.
You basically have two options.
1 - ) Either directly access your server via sockets etc.
2 - ) Or create a web service which will connect your server to the outside. ( I.e : Android Client,iOs client etc.)
The best practice is to create a web service and then consume it in your Android application.
Check these for consuming XML in Android.
http://www.ibm.com/developerworks/opensource/library/x-android/
http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/
Check these for creating web services on server side. (Stack independent)
http://davidwalsh.name/web-service-php-mysql-xml-json (PHP)
http://www.roseindia.net/webservices/buildingsimplewebservice.shtml (Java)
http://www.codeguru.com/csharp/csharp/cs_webservices/article.php/c19391/Creating-a-NET-Web-Service.htm (.NET)
And so on there are a lot of stacks to create web services.
Again, Webservice is the best approach. But you have to take decision based on the amount of the data being retrieved from the server and how often the transaction needs to be synchnorized with the server.
What Arvind was trying to explain you, incase if the volume of data is too large to download via webservice then you probably need to think of some middle tier that will convert he data to json and send it to your device. The reason, if you are transmitting the 1k of soap response over the air, for the same response, if you are transmitting thro json, it could be 100k or 200k or 300k depends. That way you can save the transmission cost over the net and turnaround time is quicker .

Fastest Way to send Data from Android to Server?

I want to send image and text data from Android phone to a Server. i am new plz suggest me the best and easy way to do this task. Server is running a java web service and i will be getting the data from server and also sending the data to server. Thanks
As your server is already there, you will have to use protocol it can uderstand - also SOAP, REST or whatever it uses. So no choice for you.
If you are deigning client-server interacton with android application, you may consider network socket communuication which has less overhead as webservices.

Send images from server to android app

I have an Android app that fetches data from the web service using ksoap2, the web service in turn fetches that information from SQL Server and sends it to the app, ksoap2 is fast and reliable and I'm happy with it.
I'm about to add a new feature which is the app will fetch multiple images from the server too. I searched for the best way to do this and I landed on three options:
keep using ksoap2 and store the images on the SQL Server, the web service will send the images in binary strings and then the app with render them and display them.
Store the images on the hard drive and use HttpUrlConnection, the web service will send the images path (url) through ksoap2 and the app will use HttpUrlConnection to download the images and display them.
Use JSon
My question is, from your experience which way should I go for? or maybe you have a better solution than that?
Thanks.
I would use option #2:
Store the images on the hard drive and use HttpUrlConnection, the web service will send the images path (url) through ksoap2 and the app will use HttpUrlConnection to download the images and display them.
This gives you the benefits of ksoap2, without a hacky workaround trying to jam images into SQL binary strings.
Additionally (and this is without knowing anything about the app you are creating) it allows you to only load the images when you actually need them, saving bandwidth, battery and memory.

Categories

Resources