473,385 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to Catch exceptions of webservices? Urgent please

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
5 5345
"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
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
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
24
by: Steven T. Hatton | last post by:
If I understand correctly, I have no assurance that I can determine the type of a simple class instance thrown as an exception unless I explicitly catch it by name. (non-derived classes having no...
8
by: Z D | last post by:
Hi, I was wondering what's the point of "finally" is in a try..catch..finally block? Isn't it the same to put the code that would be in the "finally" section right after the try/catch block?...
9
by: Steven Blair | last post by:
Hi, I need to catch exceotions on File.Delete() After checking the help, I have noticed that thgere are serevral Exceptions that can be thrown. My question is, should I catch all thes...
37
by: clintonG | last post by:
Has somebody written any guidelines regarding how to determine when try-catch blocks should be used and where their use would or could be considered superfluous? <%= Clinton Gallagher...
13
by: Benny | last post by:
Hi, I have something like this: try { // some code } catch // note - i am catching everything now {
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
4
by: cj | last post by:
my old code Try Dim sw As New System.io.StreamWriter(fileName, True) sw.WriteLine(strToWrite) sw.Close() Catch End Try my new code
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.