HttpWebRequest Not Working?

J

JS

Hi All,

I am trying to post an xml document to a java web service but I am
getting an error saying, "The remote server returned an error: (500)
Internal Server Error".

I have tried sending the xml document using Curl and it is working
fine.

I am assuming that my Request might be in the wrong format:

How can I print the HttpWebRequest to see the output of this request??

What does SOAPAction mean???
request.Headers.Add("SOAPAction", "?");

All help is appreciated.

Thanks,

JS

Below is my code:

====

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("test.xml"));

HttpWebRequest request = (HttpWebRequest) WebRequest.Create("address to
webservice");
//request.Headers.Add("SOAPAction", "?");
request.Method = "POST";
request.ContentType = "text/xml; charset=utf-8";
//request.Timeout = 30 * 1000;

Stream request_stream = request.GetRequestStream();

xmlDoc.Save(request_stream);

request_stream.Close();

WebResponse response = request.GetResponse();
Stream r_stream = response.GetResponseStream();

StreamReader response_stream =
new StreamReader(r_stream,System.Text.Encoding.GetEncoding("utf-8"));
string sOutput =response_stream.ReadToEnd();

Response.Write(sOutput);

response_stream.Close();

====
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top