zoukankan      html  css  js  c++  java
  • Web页面接受客户端POST数据,并且返回数据

    客户端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";
        }

    。。。。

    。。。。。。。

  • 相关阅读:
    Spring 事务全解析
    oracle trigger pl/sql
    reflection
    JAXP(Java API XML Parser)
    log4j扩展后的Appender
    Hibernate sql查询
    tt,mongodb主从启动命令
    4种挂隐藏链接的代码
    Delphi过程函数传递参数的几种方式
    学校Win7 KMS激活服务器已经可以用了
  • 原文地址:https://www.cnblogs.com/yesun/p/431241.html
Copyright © 2011-2022 走看看