devxlogo

GetWSException – Extracting the name of the SoapException’s inner exception

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 TryFunction 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 IfEnd Function

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist