RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: Intermediate
Mar 24, 2003



Building the Right Environment to Support AI, Machine Learning and Deep Learning

GetWSException - Extracting the name of the SoapException's inner exception

' Extract the name of the SoapException's (the type of exception thrown by a 
' web service) "inner" exception.
' Example:
'   Try
'       ' this call throws an exception
'       Dim service As New localhost.SampleService()
'       service.ThrowAnException()
'   Catch ex As SoapException When ex.Code.Equals
' (SoapException.VersionMismatchFaultCode)
'   Catch ex As SoapException When ex.Code.Equals(SoapException.ServerFaultCode)
'       lblMessage.Text = "SOAP Exception: " & ex.Message
'   Catch ex As SoapException When GetWSException(ex) = 
' "System.NullReferenceException"
'       ' get details from the OuterXml property
'       lblMessage.Text = ex.Detail.OuterXml
'   End Try

Function GetWSException(ByVal ex As System.Web.Services.Protocols.SoapException) _
    As String
    ' parse the exception's Message property.
    Dim mc As System.Text.RegularExpressions.MatchCollection = _
        System.Text.RegularExpressions.Regex.Matches(ex.Message, _
        "---> ([^:]+):")
    If mc.Count >= 1 Then
        ' we've found a match - the first ground contains the value.
        Return mc.Item(0).Groups(1).Value
    End If
End Function
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date