In .NET web services, how is the SoapException.Message property easy to read?

I am writing an ASP.NET web service and throwing a SoapException with the 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! in WebServiceException.WebService1.HelloWorld () in [DIRECTORY] \ WebService1.asmx.cs: line 23

Is there an easy way to just submit a BANG message! not the whole line? Or should I just use regular expressions?

+4
source share
1 answer

If you configure your web service to enable custom error messages, the stack trace will not be present in the SOAP error, which in turn means that 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> 
+6
source

All Articles