By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,463 Members | 2,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,463 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.