Question: I have a windows forms client that consumes an ASP.net web service.

It's my understanding that when an exception is thrown by the web service it will be converted to a SoapException in the .net client software.

Well, I am catching the SoapException, but when I display the message on the client end in a messagebox, it shows more information than I really want to show.

Here is the webservice code:

```
throw new ApplicationException("Invalid username or password.");

```

Or even:

```
throw new SoapException("Invalid username or password.", SoapException.ServerFaultCode);

```

But on the client end, the SoapException's Message property is this:

```
System.Web.Services.Protocols.SoapException: Invalid username or password. at Transportation.InsertSignUps(String username, String password, SignUp[] signUps) in c:\Documents and Settings\rdoverby\My Documents\Visual Studio 2008\WebSites\www.gtcc.edu\App_Code\webservices\Transportation.cs:line 50
```

Whereas, all I really want to show is:

```
Invalid username or password.
```

How can I extract ONLY the original exception's message from the SoapException. I have poked around the SoapException object in the VS debugger, but I can't find what I am looking for.

Thanks.

EDIT
----

Of course, I don't want to parse that long string.

Answer: 
if the exception is a soapException (se) then you can get to the most important bits by using something like se.Detail.FirstChild.OuterXml which is where the Exception is usually placed or if you want the lot then se.Detail.OuterXml
Don't be too disappointed:)

I've did the same with the help of this article: <http://www.developer.com/net/csharp/article.php/3088231>.

I've created one custom class for my exceptions, and it even has the real Exception as an InnerException encapsulated in it. (I've added a language-independent ID to every known type of my custom Exceptions, to make it more usable for my clients.)

On the client side, I just get the InnerException, and InnerException.Message is the original text, without any garbage.