As i mentioned at the title i've got a internet data usage problem.
I've got an ASMX (C#) Web service which returns an average 400 Byte JSON string/array, when i use KSOAP2 to get it in my android application it's showing 1.7 KB Data in TrafficStats class.
I checked everyting and all code parts which related to measuring data usage are true, i mean even i checked my phone operator about data usage for last 1 hour to control my codes.
How can i decrease this data usage? Thanks.
Note: Maybe a compression or an explanation why data turns into 1.7 KB when it's only 400 Bytes can help me a lot.
Bounty Edit:Sorry about bounty but your answer doesn't meet the requirements of solution..
As explained in comments returning a json string in a SOAP+XML brings a lot of overhead.
you can configure your asmx service using ScriptMethod
and ScriptService
attributes to return directly json. That way, you can directly return your object from that method instead of returning a string.
Now your modified method will be something like this:
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
[WebMethod]
public MyClass GetID(string id)
{
var myobj = new MyClass();
//instead of serializing your object manually and returning a string
//directly return your object. Webservice will do it for you.
return myobj;
}
Also make sure the request is a POST
, not a GET
(here is the explanation)
PS: Enabling Http compression may help too . http://www.iis.net/configreference/system.webserver/httpcompression