To my knowledge, unfortunately, the answer is no. You cannot create your own custom exceptions on the server side and expect to use them on the client side through WSE. I cannot give a lot of technical assumptions as to why (how and why this is not allowed by WSE), but I am sure of my answer because I checked it.
You can use the approach described in the provided link to return a custom exception that is inherited from System.Web.Services.Protocols.SoapException, however you must catch the client-side exception as a SoapException, since you will not be able to catch it as a custom exception type : http://msdn.microsoft.com/en-us/library/ms229064.aspx
To recreate the test for your own confirmation, follow these steps:
- Create a test exception class, call it what you want, and make sure that it matches the pattern described in the link above (there are code examples).
Create a web method that explicitly returns a test exception, for example:
'This is in VB.Net <WebMethod()> _ Public Function ThrowTestSoapException() As TestSoapException Return New TestSoapException() End Function
Try to restore the WSE client library (using WseWsdl3.exe), and you will get an error message similar to this: "Error: server is unavailable, try again later"
This is how much I can get when I try to create my own custom custom exceptions. Again, the only thing I could do was return a custom exception inherited from the SoapException class and caught it on the client side as a SoapException. This is the same method described in the link that "CheGueVerra" indicated above .
In response to John Saunders comment above: Yes, if it's possible to upgrade to WCF, the WSE is really out of date. Since this is a job for me and for others asking these questions, moving from WSE to WCF will require management approval - so some of us cannot easily make these changes - even if we desperately want to.
source share