Xamarin Android Questions and Issues when working with WebServices (SOAP .NET 2.0)


I've been working with Xamarin and Webservices (Stated as .NET 2.0 Webservice in Xamarin) in the past few weeks. And I've runned into a few problems that I couldn't figure a workaround yet.

1st) How do I set a timeout for the webservice? The Timeout property is ignored regardless of its value. I believe the default being used is something around 30 seconds. But I'd like 5 seconds~~.

2nd) When the WebService call any method async, using the Begin. Is there anyway to check whether the async method was completed correctly or was timed out? The only way I got to "check" is by perfoming a try/catch in the End method. If it was fired because of a timeout, it will raise an exception. But I wonder if there is some property or method somewhere that would tell me if the webservice call did timeout or was processed correctly. The webservice method being used here is "IsAlive".

WebService.MainService.BeginIsAlive ((ar) => { try { bool result = WebService.MainService.EndIsAlive (ar); //If timedout will raise an exception. RunOnUiThread (() => { Toast.MakeText (this, "Running as expected...", ToastLength.Long).Show(); }); StartActivity (typeof(OtherScreen)); } catch (Exception ex) { //Probably timeout. } }, null);

3rd) Is there a way to Cancel a webservice async operation? Such as "CancelIsAlive". The only method I found was Webservice.Abort. But I do not believe it is a best practice and since it is not specific, it may screw everything up.

Thanks in advance, Luís Henrique.


That's what usually I do for calling WebServices and having control on them (assume your ws function needs an string and returns an string):

public static void CallSomeFunction(string SomeParameter, Action<string> Ok, Action Error, Activity Context) { ThreadPool.QueueUserWorkItem ((object e) => { var proxy = new YourProxyClass(); proxy.Timeout = 10000; try{ var res = proxy.YourFunction(SomeParameter); Context.RunOnUiThread(() => Ok(res)); } catch(Exception Ex){ if(Error != null) Context.RunOnUiThread(Error); } }); }

This is how I do asynchronous tasks, use the ThreadPool to make synchronous calls, and pass some Actions to execute if all is ok or wrong. Also I'm passing a Context so my Ok and Error actions be executed in the UI thread.


  • Android Background Service That Runs Forever
  • Android: how to communicate from worker thread to a service
  • rendaring issue with surfaceview in viewflipper?
  • Unable to connect to the server: dial tcp accounts.google.com :443: getsockopt: operation timed out
  • Python close a thread on multithreading
  • How can code within a Task know that it has timed out?
  • Issue to parse json
  • Unable to integrate Github with Pycharm
  • Python: Timeout Exception Handling with Signal.Alarm
  • HttpURLConnection error: java.net.SocketTimeoutException: Connection timed out
  • Session timeout in Java EE
  • Running Laravel Dusk on Homestead
  • RestSharp in Mono project (MonoDevelop)
  • mysql aggregate functions in query with two joins gives unexpected results
  • Any clues about MediaPlayer Info/Warning 950?
  • Client Webservice in java - proxy authentication
  • Single node Cassandra behaving like multinode Cassandra
  • BIND . Registrar says it cant find the nameserver. nslookup shows the domain is being handled by bin
  • provisioning profile -request timed out Xcode
  • Error with connecting to wsdl?
  • every time creating new thread is being added to main ThreadGroup
  • Open source augmented reality framework for BlackBerry
  • Building libiconv fails with the Android standalone toolchain
  • Preventing execution pause when dragging game window
  • How to graph streaming data in C#
  • SQL Server - Get all children of a row in many-to-many relationship?
  • EJB @Schedule issue
  • ASP.NET 2.0 Session Timeout
  • What are zone turns?
  • JSON encode and decode on PHP
  • How to estimate the Kalman Filter with 'KFAS' R package, with an AR(1) transition equation
  • Fail:(TESTMODE) Transactions of this market type cannot be processed on this system
  • When should I choose bucket sort over other sorting algorithms?
  • Android Studio and gradle
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Observable and ngFor in Angular 2
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?