views:

626

answers:

3

Hi All

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

Thanks Subhasis

+1  A: 

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.

BrianLy
the server code is just [WebMethod] public void GetSoapException() { throw new SoapException(); }So there is no possibility of it being wrong.
Subhasis
Right...I can pass something to SoapException constructor (infact i have already tried it) but at the end I need to throw that exception...Am I wrong here?Will throwing an exception always cause "server error - 500"? If so how can i get the fault in response XML.
Subhasis
A: 

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

Chrisb
No its not working if I directly open the asmx from IE and invoke the method, the next screen I get is "HTTP 500 internal server error"
Subhasis
A: 

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

Subhasis