Calling webservice with exception inside a try/catch do not catch

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling webservice with exception inside a try/catch do not catch

eternalbard
Greetings, I'll try to explain a problem and sorry if I'm not so clear:

I have some UITextView fields that are normally 300 character limit size. As until today I didn't know how to block this, and didn't know that Sqlite accepts whatever limit of characters, I found that when devices sync with server, there was happening, in rare cases (from 800 users just 6), a truncate exception from SQL Server inside a webservice method.

The thing is that the webservice method call is inside a try, and no catch is being catched, the code is like:

string Ret;
TheASMXWebService.Syncro webService = new TheASMXWebService.Syncro();
try
{
Ret = webService.ExecuteSomethingRemote(StringWith300InSize);
}
catch (WebException ex)
{
MessageBox.Show(ErrorHandler.DisplayWebServiceErrors(ex));
return;
}

On Windows and Windows Mobile if an exception comes from webservice, from ADO.NET or other thing, the exception is passed to the method calling the webservice (ExecuteSomethingRemote()) and it's catch on try/catch, and the UIAlertView is shown (MessageBox has the while()-wait-for-0.5-seconds-tip-from-Miguel).

What I'm doing wrong? Nothing goes to catch(), it stops inside webService.ExecuteSomethingRemote that was generated by MonoDevelop or is one of the ReturnATableFromWebService that I copy from VisualStudio version of the project on Windows Mobile, because MonoDevelop do not create webservice proxy/code when it returns Tables, that is something like:

 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.blabla.com.br/TheASMXWebService/ExecuteSomethingRemote", RequestNamespace="http://www.blabla.com.br/TheASMXWebService", ResponseNamespace="http://www.blabla.com.br/TheASMXWebService", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
        public string ExecuteSomethingRemote(string StringWith300InSize) {
            object[] results = this.Invoke("ExecuteSomethingRemote", new object[] {
                       StringWith300InSize});
            return ((string)(results[0]));
        }

This all runs perfectly (on Windows, Windows Mobile, iOS and Android) but just do not catch the exception from the server (don't know on Android yet, it's still without UI). I just get that problem using debugger because no messages appear to the user, just the application close. And as the user can't get database from ipad and send by email, I ported a send database file to server to test one of the 6 problematic databases on emulator, as we can't copy manually to device.

Thanks,

Karl

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: Calling webservice with exception inside a try/catch do not catch

Robert Jordan
On 30.04.2011 06:53, Karl Heinz Brehme Arredondo wrote:

> Greetings, I'll try to explain a problem and sorry if I'm not so clear:
>
> I have some UITextView fields that are normally 300 character limit size. As
> until today I didn't know how to block this, and didn't know that Sqlite
> accepts whatever limit of characters, I found that when devices sync with
> server, there was happening, in rare cases (from 800 users just 6), a
> truncate exception from SQL Server inside a webservice method.
>
> The thing is that the webservice method call is inside a try, and no catch
> is being catched, the code is like:

You're catching only WebExceptions. If the service proxy
is throwing a different exception, you won't be able to catch it
with this code.

Try to debug with "catch (Exception ex)".

>
> string Ret;
> TheASMXWebService.Syncro webService = new TheASMXWebService.Syncro();
> try
> {
> Ret = webService.ExecuteSomethingRemote(StringWith300InSize);
> }
> catch (WebException ex)
> {
> MessageBox.Show(ErrorHandler.DisplayWebServiceErrors(ex));
> return;
> }

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch