HttpWebRequest Not Working?

Discussion in 'ASP .Net Web Services' started by JS, Sep 18, 2006.

  1. JS

    JS Guest

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

    ====
     
    JS, Sep 18, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Washburn

    HttpWebRequest is not posting

    Jeff Washburn, Jul 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    384
    Jeff Washburn
    Jul 28, 2003
  2. =?Utf-8?B?TWFydmlu?=

    httpWebRequest not sending client Certificate

    =?Utf-8?B?TWFydmlu?=, Aug 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,686
    Jens Christian Mikkelsen
    Aug 8, 2004
  3. GlennLanier
    Replies:
    2
    Views:
    21,300
    GlennLanier
    Jun 10, 2005
  4. =?Utf-8?B?RGF2ZSBCcm93bg==?=

    HttpWebRequest POST result is not the same as POST via ServerXMLHT

    =?Utf-8?B?RGF2ZSBCcm93bg==?=, Nov 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,145
    Joerg Jooss
    Nov 10, 2005
  5. Replies:
    0
    Views:
    882
Loading...

Share This Page