Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
捕获SOAP异常.NET_.net_Exception_Soap - Fatal编程技术网

捕获SOAP异常.NET

捕获SOAP异常.NET,.net,exception,soap,.net,Exception,Soap,我想知道如何正确捕获soap异常。我只能将其捕获为system.net.webexception(错误500 HTTP),但不能捕获为soapheaderexception或soap异常 我目前的代码是: Try 'Code Catch soapExcpHeader As System.Web.Services.Protocols.SoapHeaderException 'Can't catch here Dim error_des

我想知道如何正确捕获soap异常。我只能将其捕获为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

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

尝试查看异常的GetType()属性的值,如果您的catch块没有在System.Web.Services.Protocols.SoapHeaderException上停止,则表示您的异常没有继承它