469,271 Members | 1,063 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Error on web service: "Server returned internal error 500"

Hi,

I'm really going mad about this! Currently I'm designing a student
course on web services. Because I want them to understand what's really
going on when web services correspond with each other (or other
consumers) via SOAP, I want to generate SOAP-messages in XML manually
and send it via POST-method to the hosting server.

But whenever I try to use HttpWebRequest-Class to get a response from a
webservice, I get an "Internal Server Error (500)" on response. I've
searched the web for similar problems (and indeed I've found a lot),
but I could not find a working solution.

Here is my source code:

************************************************** ****************
String soap = "<soap12:Envelope
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"<soap12:Body>
<serviceMetod xmlns=\"http://server:8080/WebService.asmx\"<date>some
date</date<headline>some headline</headline<news>some news</news>
<author>some author</author</serviceMetod</soap12:Body>
</soap12:Envelope>";

WebRequest wReq =
WebRequest.Create("http://server:8080/WebService.asmx");
HttpWebRequest httpReq = (HttpWebRequest)wReq;

httpReq.Method = "POST";
httpReq.ContentLength = soap.Length;
httpReq.ContentType = "application/soap+xml;charset=utf-8";
httpReq.Headers.add("SOAPAction http://someuri.net/serviceMethod");
Stream sendStream = httpReq.GetRequestStream();
StreamWriter strmWrtr = new StreamWriter(sendStream);
strmWrtr.Write(soap);
strmWrtr.Close();

string sResult;
try
{
//next line will produce the error
WebResponse wResp = httpReq.GetResponse();
Stream respStrm = wResp.GetResponseStream();
StreamReader strmRdr = new StreamReader(respStrm);
sResult = strmRdr.ReadToEnd();
Console.WriteLine(sResult);
}
catch (Exception Ex)
{
sResult = "Web Request returned error: " + Ex.Message;
Console.WriteLine(sResult);
}
************************************************** ****************

I'm using IIS 6 and VS 2005. Maybe this is an IIS-configuration
problem?

Any help would be really appreciated!

Thanx in advance

Tito

Dec 15 '06 #1
1 7915
Hi,
Why dont you use microsoft soap toolkit for intercepting the
soap messages and find out the exact error.
I hope this resolves your problem.
thanks,
Nis
Tito Meinrath wrote:
Hi,

I'm really going mad about this! Currently I'm designing a student
course on web services. Because I want them to understand what's really
going on when web services correspond with each other (or other
consumers) via SOAP, I want to generate SOAP-messages in XML manually
and send it via POST-method to the hosting server.

But whenever I try to use HttpWebRequest-Class to get a response from a
webservice, I get an "Internal Server Error (500)" on response. I've
searched the web for similar problems (and indeed I've found a lot),
but I could not find a working solution.

Here is my source code:

************************************************** ****************
String soap = "<soap12:Envelope
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"<soap12:Body>
<serviceMetod xmlns=\"http://server:8080/WebService.asmx\"<date>some
date</date<headline>some headline</headline<news>some news</news>
<author>some author</author</serviceMetod</soap12:Body>
</soap12:Envelope>";

WebRequest wReq =
WebRequest.Create("http://server:8080/WebService.asmx");
HttpWebRequest httpReq = (HttpWebRequest)wReq;

httpReq.Method = "POST";
httpReq.ContentLength = soap.Length;
httpReq.ContentType = "application/soap+xml;charset=utf-8";
httpReq.Headers.add("SOAPAction http://someuri.net/serviceMethod");
Stream sendStream = httpReq.GetRequestStream();
StreamWriter strmWrtr = new StreamWriter(sendStream);
strmWrtr.Write(soap);
strmWrtr.Close();

string sResult;
try
{
//next line will produce the error
WebResponse wResp = httpReq.GetResponse();
Stream respStrm = wResp.GetResponseStream();
StreamReader strmRdr = new StreamReader(respStrm);
sResult = strmRdr.ReadToEnd();
Console.WriteLine(sResult);
}
catch (Exception Ex)
{
sResult = "Web Request returned error: " + Ex.Message;
Console.WriteLine(sResult);
}
************************************************** ****************

I'm using IIS 6 and VS 2005. Maybe this is an IIS-configuration
problem?

Any help would be really appreciated!

Thanx in advance

Tito
Dec 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bruce Schechter | last post: by
1 post views Thread by Greg Burns | last post: by
1 post views Thread by phranque | last post: by
2 posts views Thread by Sosa | last post: by
2 posts views Thread by Andy Chen | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.