SoapException - how do I get inner ApplicationException?

S

Stan

My web service throws ApplicationException which resulut in SoapException on the client and this error message

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ApplicationException: Trailer '53-7092a' is invalid or not in the system at Sender.Sender.Prepare(String xml) in c:\inetpub\wwwroot\sender\sender.asmx.cs:line 38 --- End of inner exception stack trace ---

I would like to show only the ApplicationException message - "Trailer is invalid" (this is what web service throws

However, InnerException is null.

How do I get it, then

Thanks

-Sta
 
M

[MSFT]

Hi Stan,

The exception is thrown by web service client proxy and InnerException is
not set yet. To get the "inner" exception message, I suggets you may
decompose the exception like:

System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> System.ApplicationException: Trailer '53-7092a' is invalid or
not in the system at Sender.Sender.Prepare(String xml) in
c:\inetpub\wwwroot\sender\sender.asmx.cs:line 38 --- End of inner exception
stack trace ---

For example, you can retrieve the string between "--->" and "at Sender".

Or you may consider pass the exception information from your web method.
For example, add try-catch statement in the web method and return a string

Hope this help.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Stan

Jan

Thanks for your post. In my opinion your method is too complicated. I can achive the same results with

===
catch (Exception ex

string msg = ex.Message
int PosStart = msg.IndexOf ("-->")
int PosEnd = msg.IndexOf ("--- End")
lblError.Text = msg.Substring (PosStart + 3, PosEnd - PosStart - 3)


===

Four lines of code - it is all it takes as opposed to many helper classes, nested try/catches..

I just don't think I can justify all that code if can put the above four lines.. I can even make it more neat by wrapping into a some sort of helper class. The benefit is that I don't need to modify my server code..

Just an opinion..

thanks

-Stan
 
J

Jan Tielens

Stan

By using your solution your rely on the formatting of the .NET Framework. If
some characters change in the next version, your code will break. Or if you
switch to a Java server, the formatting of the message will be different.

But of course that's my opinion. Your code will work of course, but has some
restrictions.

--
Greetz,
Jan
________________________
Read my weblog: http://weblogs.asp.net/jan

Stan said:
Jan,

Thanks for your post. In my opinion your method is too complicated. I can achive the same results with:

====
catch (Exception ex)
{
string msg = ex.Message;
int PosStart = msg.IndexOf ("-->");
int PosEnd = msg.IndexOf ("--- End");
lblError.Text = msg.Substring (PosStart + 3, PosEnd - PosStart - 3);
}

====

Four lines of code - it is all it takes as opposed to many helper classes, nested try/catches...

I just don't think I can justify all that code if can put the above four
lines.. I can even make it more neat by wrapping into a some sort of helper
class. The benefit is that I don't need to modify my server code...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top