asp.netweb-servicessoapsoap-clientsoapexception

show webservice soapexception response in the client in ASP.NET


I am trying to make a Test Webservice and throw a SoapException. But when I open the service through browser, it shows Internal server error - 500.

If i try to consume it manually by sending a manually created SoapRequest (in stringbuilder), I get the same error "Servererror - 500" in Visual Studio itself in the line "WebResponse response = req.GetResponse()"

Is there anyway I can actually see the "fault in response XML".


Solution

  • after surfing through for 5-6 hours finally got it......here it is:

    When you are getting the response manually, use the following:

    try
    {
        WebResponse response = req.GetResponse();                
        Stream str = response.GetResponseStream();
        StreamReader rdr = new StreamReader(str);
        Response.Write(rdr.ReadToEnd());          
        Response.End();
    }
    catch (WebException webEx)
    {
        Stream str = webEx.Response.GetResponseStream();
        StreamReader rdr = new StreamReader(str); 
        Response.Write(rdr.ReadToEnd());          
        Response.End();
    }