0

我想如何正确捕获肥皂异常。我只能将其作为 system.net.webexception(错误 500 HTTP)捕获,但不能作为soapheaderexception 或soap 异常捕获。

我目前的代码是:

Try
       'Code

Catch soapExcpHeader As System.Web.Services.Protocols.SoapHeaderException
            'Can't catch here
            Dim error_desc As String = soapExcpHeader.Detail.OuterXml
            Throw New System.Web.Services.Protocols.SoapHeaderException()
Catch soapExcp As System.Web.Services.Protocols.SoapException
            'Can't catch here
            Dim error_desc As String = soapExcp.Detail.OuterXml
            Throw New System.Web.Services.Protocols.SoapException
Catch webExcp As System.Net.WebException
             'Here I catch
            Console.WriteLine(webExcp.ToString())
            Throw webExcp
Catch ex as Exception
             'Other types of exceptions
             Throw ex
End Try

一如既往地感谢您的回复。

4

1 回答 1

0

尝试查看您的异常的 GetType() 属性的值是多少,如果您的 catch 块没有在 System.Web.Services.Protocols.SoapHeaderException 上停止,这意味着您的异常不会继承它。

于 2012-06-29T13:00:58.660 回答