By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

How to Catch exceptions of webservices? Urgent please

P: n/a
Hi all,

How to handle exceptions of webservices?
I have a wsdl file which contains the exception classes.

when i am adding that wsdl file in my asp application I am unable to view
those classes.

As of now i am catching through EXCEPTION class. I know this is not the
permanent solution. Please help in solving this...

Thanks in advance
Kris.
Apr 20 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"kris" <kr**@discussions.microsoft.comwrote in message
news:60**********************************@microsof t.com...
Hi all,

How to handle exceptions of webservices?
I have a wsdl file which contains the exception classes.
Are you referring to SOAP Faults in the WSDL, or are you referring to
something else. If something else, then please post an example of one of
these "exception classes".
when i am adding that wsdl file in my asp application I am unable to view
those classes.

As of now i am catching through EXCEPTION class. I know this is not the
permanent solution. Please help in solving this...
The ASP.NET Web Services handler translates any uncaught exception other
than a SoapException _into_ a SoapException. SoapExceptions are (mostly)
left alone.

When it sees a SoapException, it translates that into a SOAP Fault and
returns that to the client.

If the client is a .NET Client, it will turn that SOAP Fault into a
SoapException and will throw that.

You cannot recover the original exception.

If you have clients other than .NET clients (I don't know how this works
with WCF clients), then you may be interested in having them turn your SOAP
Faults into exceptions they can catch. Java clients can do this, for
instance. If that's what you're looking for, let me know.
--

John Saunders [MVP]
Apr 21 '07 #2

P: n/a
Hi John

I found the solution for this.

To catch the exceptions of wsdl

catch(SoapException ex)
{
ex.Detail.InnerText; // Gives me in detail about the exception
}
Any way, Thank u very much.
Apr 23 '07 #3

P: n/a
"kris" <kr**@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
Hi John

I found the solution for this.

To catch the exceptions of wsdl

catch(SoapException ex)
{
ex.Detail.InnerText; // Gives me in detail about the exception
}

Note that ex.Detail.InnerText will only give you detail about the exception
if someone has put some detail there. You're also losing any structure to
the detail by using .InnerText, as there may be arbitrary XML in .Detail.
Finally, .Detail may be null, so test that before taking .InnerText.
--

John Saunders [MVP]
Apr 24 '07 #4

P: n/a
hi

I can see even the exception class name in ex.Detail.OuterXml.

How to retrieve that class so that i can catch in that class instead of
SOAPEXCEPTION class.

Apr 24 '07 #5

P: n/a
"kris" <kr**@discussions.microsoft.comwrote in message
news:81**********************************@microsof t.com...
hi

I can see even the exception class name in ex.Detail.OuterXml.

How to retrieve that class so that i can catch in that class instead of
SOAPEXCEPTION class.
You can't, because you're not seeing the class name. You're seeing some text
that _looks_ like a class name. It's just a text message, and the format of
it is subject to change at any time. Do not use it for any purpose other
than to display the text of the message or log it to the event log or
somewhere.

If Microsoft had been attempting to send you the class name, they would have
sent it in the standard full format. Something like this:
"System.Configuration.AppSettingsSection, System.Configuration,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

Also, if Microsoft had intended you to catch specific exceptions, they would
have done it for you, and not required you and everyone else to do it
yourself.

So, please do yourself a favor and stop there; any further will be a hack,
and likely a fragile one at that.

--
John Saunders [MVP]
Apr 24 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.