Using custom exceptions in wse, not just SoapException

Is it possible to send my own developed Soap exceptions to the client using http.sys?

+4
source share
3 answers

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.

+1
source

Yes, you can throw your own exceptions. Any uncaught exception that does not result from a SoapException will be blurred by the .NET framework in SoapException. You can get from SoapException if you want to control how certain parts of SoapException are generated (for example, parts with an error and details).

0
source

Like ASMX services, based on this, the WSE has little support for SOAP Faults. You can return them (SoapException with a set of Detail properties), but they will not be displayed in WSDL. If received by the WSE client, they will be displayed as a SoapException, and not as a custom exception type.

WCF fully supports SOAP errors, both on the client side and on the server side.

0
source

Source: https://habr.com/ru/post/1277210/


All Articles