Use Request to receive xml data that send by using HttpWebRequest,

Discussion in 'ASP .Net' started by Ying-CO, Jun 5, 2008.

  1. Ying-CO

    Ying-CO Guest

    Here are my sending data part of the code:
    -----------------------------------
    XmlTextWriter myWriter = null;
    HttpWebRequest myRequest;

    XmlTextReader myXMLReader = null;
    XmlDocument myDoc = null;

    myDoc = new XmlDocument();
    myDoc = Miscellaneous.CreateXMLDoc(); // will return a xml doc

    // post xml file
    myRequest =
    (HttpWebRequest)WebRequest.Create("http://localhost:2772/Default.aspx");

    myRequest.Method = "POST";
    myRequest.ContentType = "text/xml";
    myRequest.KeepAlive = false;
    try
    {
    myWriter = new
    XmlTextWriter(myRequest.GetRequestStream(),System.Text.Encoding.UTF8);
    //myDoc =
    Miscellaneous.CreateXMLDoc(txtLogin.Text,SubmissionInfo.StrPasswd);
    myDoc.WriteContentTo(myWriter);
    myWriter.Flush();
    myWriter.Close();
    }.............

    Here is my receving data code in Default.aspx.cs file
    ---------------------------------------------------------
    // Get input from client
    HttpContext con = Context;
    HttpRequest httpReq = con.Request;
    httpReq.ContentType = "text/xml";
    httpReq.RequestType = "GET";

    XmlTextReader myXMLReader = new
    XmlTextReader(httpReq.InputStream);

    if (httpReq.InputStream.Length != 0)
    {
    }

    The problem is the length of httpReq.InputStream is 0. Can you tell me
    what's wrong?

    Thank you very much in advance,
    Ying
    Ying-CO, Jun 5, 2008
    #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. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,031
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  2. arti
    Replies:
    0
    Views:
    563
  3. Steve Holden
    Replies:
    0
    Views:
    760
    Steve Holden
    Apr 11, 2008
  4. Guest
    Replies:
    2
    Views:
    898
    Juan T. Llibre
    Aug 17, 2009
  5. John Dow

    How to receive/send XML file through HTTP Post?

    John Dow, Oct 9, 2007, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    695
    JIGNESH
    Oct 9, 2007
Loading...

Share This Page