472,133 Members | 1,020 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

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 8061
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.