This is a common problem because web services usually send you an HTTP 500 error (Internal server error) when encountering an unhandled exception. I am using a trick that I found a long time ago. Basically, you need to drill through a WebException using StreamReader to determine the root cause of the exception.
Code example: (Sorry, you did not have a C # code, please use a converter)
Try 'Hit the webservice. Catch ex As WebException Dim r As HttpWebResponse = CType(ex.Response(), HttpWebResponse) Using sr As StreamReader = New StreamReader(r.GetResponseStream()) Dim err As String = sr.ReadToEnd() 'Log the error contained in the "err" variable. End Using Return Nothing Finally 'Clean up End Try
It can be converted using the DeveloperFusion converter , which I highly recommend.
source share