stock stack trace from showing in soapexception

J

Jeremy

I've written a web service, with a try catch in my web method. In the
catch, I create a new SoapException instance with a message of "Error Here".
Then I throw the SoapException. In my calling application I call the web
service inside a try catch. When I catch the SoapException, the message
property of the exception is "System.Web.Services.Protocols.SoapException:
Error Here at MyWebService.HandleException(Exception ex) at
MyWebService.MyWebMethod()"

When I throw the SoapException, why does it append the stack trace to the
message, and put "System.Web.Services.Protocols.SoapException: " at the
beginning of the message? Is it possible for me to tell it to retain the
actual message? All I want the calling application to see is the value I
put in the message property.
 
T

Tiago Halm

You need to suppress the exceptions. Add this to your web.config:

<webServices>
(...)
<diagnostics suppressReturningExceptions="true"/>
</webServices>

Tiago Halm
 
J

John Saunders [MVP]

Jeremy said:
I've written a web service, with a try catch in my web method. In the
catch, I create a new SoapException instance with a message of "Error
Here". Then I throw the SoapException. In my calling application I call
the web service inside a try catch. When I catch the SoapException, the
message property of the exception is
"System.Web.Services.Protocols.SoapException: Error Here at
MyWebService.HandleException(Exception ex) at MyWebService.MyWebMethod()"

When I throw the SoapException, why does it append the stack trace to the
message, and put "System.Web.Services.Protocols.SoapException: " at the
beginning of the message? Is it possible for me to tell it to retain the
actual message? All I want the calling application to see is the value I
put in the message property.

You should experiment with the customErrors element in web.config. Either
"off" or "on" will work, whichever is opposite of what you currently have.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top