夜隼

RYSZ

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
客户端post数据到asp.net页面

WebRequest wrPostURL = WebRequest.Create("http://edzh.com/Get.aspx");
    wrPostURL.Method = "POST";
    Stream postStream = wrPostURL.GetRequestStream();

//Dom为需要post的数据
    byte[] pPostBytes = System.Text.Encoding.UTF8.GetBytes(DOM.OuterXml);
    postStream.Write(pPostBytes,0,pPostBytes.Length);
    postStream.Flush();
    postStream.Close();

//responseStream为返回的xml数据

    Stream responseStream = wrPostURL.GetResponse().GetResponseStream();

    try
    {
     XmlDataDocument objXML = new XmlDataDocument();
     objXML.Load(responseStream);
     return objXML;
    }
    catch(XmlException ex)
    {
     throw new Exception(ex.ToSting())
    }

-------------------------------------------------

Get.aspx页面部分代码

//接受POST数据
    XmlDataDocument xmlDoc = new XmlDataDocument();
    try
    {

//Request.InputStream为post的数据,xml格式
     xmlDoc.Load(Request.InputStream);
    }
    catch/*(Exception ex)*/
    {
     //xml格式错误
     returnDesc += "Invalid XmlDocument";
    }

。。。。

。。。。。。。

posted on 2006-06-21 10:13  夜隼  阅读(1015)  评论(0编辑  收藏  举报