2012-06-29 129 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上,則表示您的異常不會繼承它。