devxlogo

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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Engineering Leaders Spot Weak Proposals

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.