2012-06-29 126 views
0

我想如何正确地捕捉肥皂异常。我只能将它作为system.net.webexception(Error 500 HTTP)捕获,但不能作为soapheaderexception或soap异常捕获。捕捉SOAP异常.NET

我当前的代码是:

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 

一如既往感谢您的答复。

回答

0

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