Question

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".

Was it helpful?

Solution 3

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();
}

OTHER TIPS

It sounds like there is something wrong with the service and you need to debug it on the server side rather than the client side. I come to this conclusion because you have a problem with your client code and a web browser.

Assuming you are using .NET have you enabled display of ASP.NET errors on the server? See this article for info.

Update:

So you are throwing an error on the server and want to get the error text on the client? An error on the server is supposed to result in a 500 error message and is unlikely to return any XML to the client. Perhaps you can pass something to the SoapException constructor?

Have you looked at the docs for SoapException? They have some examples of passing information using the Detail property of SoapException.

Can you get to the asmx (assuming you are using asmx) in the browser to see if it is working at all?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top