views:

39

answers:

1

I am writing an ASP.NET web service and am throwing a SoapException with a message:

throw new SoapException("BANG!", SoapException.ClientFaultCode);

When I create an ASP.NET client, and request a label to display the SoapException.Message property, it displays a message similar to the following:

System.Web.Services.Protocols.SoapException: BANG! at WebServiceException.WebService1.HelloWorld() in [DIRECTORY]\WebService1.asmx.cs:line 23

Is there an easy way to simply be presented with the message BANG! rather than this entire string? Or should I just use regular expressions?

+1  A: 

If you configure your web service to turn on custom error messages, the stack trace will not be present in the SOAP fault, which in turn will mean your client will not see it.

In web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    ...
    <system.web>
        ...
        <customErrors mode="On"/>
        ...
    </system.web>
    ...
</configuration>
GBegen