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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?WWluZy1DTw==?=

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

    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.C reateXMLDoc(); // will return a xml doc

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

    myRequest.Metho d = "POST";
    myRequest.Conte ntType = "text/xml";
    myRequest.KeepA live = false;
    try
    {
    myWriter = new
    XmlTextWriter(m yRequest.GetReq uestStream(),Sy stem.Text.Encod ing.UTF8);
    //myDoc =
    Miscellaneous.C reateXMLDoc(txt Login.Text,Subm issionInfo.StrP asswd);
    myDoc.WriteCont entTo(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.Content Type = "text/xml";
    httpReq.Request Type = "GET";

    XmlTextReader myXMLReader = new
    XmlTextReader(h ttpReq.InputStr eam);

    if (httpReq.InputS tream.Length != 0)
    {
    }

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

    Thank you very much in advance,
    Ying


Working...