5

I am calling a web service from my Android application. I have many different calls to this service all through the application and every one of them is returning data in less than a second, except for one. One of my calls can take up to a minute to return the data even though the actual web service call is near instantaneous. The problem occurs with the line:

transport.call(SOAP_ACTION, soapEnvelope);

That is called and the value is returned from the web service almost instantaneously. But it can take up to a minute to reach the next line:

SoapObject result = (SoapObject) soapEnvelope.bodyIn;

What is happening between the web service returning data and the app hitting the next line (above)? Is there a way to reduce this delay? Is there anything simple to check?

anothershrubery
  • 20,461
  • 14
  • 53
  • 98
  • are you sure the result is that fast ? it is possible the server keeps the connection opened for some reason – njzk2 Mar 22 '13 at 14:19
  • Yeah, when I go to the web service location in a web browser it returns results instantaneously. And when remotely debugging the web service the delay is from when the fucntion returns the string until the line `SoapObject result = (SoapObject) soapEnvelope.bodyIn;` so there is no delay in the web service. And all other calls to the web service use the exact same code for the requests, just changing a couple of variables and they are fine. – anothershrubery Mar 22 '13 at 14:46

2 Answers2

1

Is there a way to reduce this delay? Is there anything simple to check?

The only way to know is to measure the difference in time in various areas. For a SOAP web service call these are the times to measure.

Client side time

Client Application code -> Request Handlers -> Request Serialization -> Request dispatch -> HTTP Transport -> Server side

Server side time

Receive HTTP Request -> De-serialization -> Application code -> Response handlers -> Serialization -> Dispatch -> HTTP Transport

The blockage is usually in the application code, handlers and the network. Measure those and you can find where the time is spent.

  • To measure CPU time taken by your application code and handlers use a profiler. I'd recommend Jprofiler.
  • To measure network time, ping the target server and also use a web debugging proxy like Charles. It can tell you the time spent by the request on the network.
Community
  • 1
  • 1
Deepak Bala
  • 11,095
  • 2
  • 38
  • 49
  • I know where the delay is, it's within the ksoap2 3rd party library, specifically in the `HttpTransportSE.call()` method. I'm looking for a way to address this delay or seeing what is happening with this piece of code that might be causing the delay. – anothershrubery Mar 25 '13 at 12:26
1

Turns out the delay was only while debugging the app. When running the app without the debugger attached it returns near instanteously.

anothershrubery
  • 20,461
  • 14
  • 53
  • 98