zoukankan      html  css  js  c++  java
  • 以post方式发送文档到端口

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    using System.Xml;
    using System.Net;
    using System.IO;

    namespace WindowsFormService
    {
    public class HttpSend
    {

    public XDocument sendXmlAndGetResponse(XDocument xDocument)
    {
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xDocument.Document.ToString());
    WebResponse resp;
    string strUrl = XMLTools.getXmlValue("LFListenerAddress", "Address");// "http://localhost:8008/hello/";
    HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
    myRequest.ContentType = "text/xml";
    myRequest.Method = "POST";
    Stream stm = myRequest.GetRequestStream();
    doc.Save(stm);
    stm.Close();
    resp = myRequest.GetResponse();
    stm = resp.GetResponseStream();
    //StreamReader r = new StreamReader(stm);
    //MessageBox.Show(r.ReadToEnd().ToString(), "MESSAGE ");

    var reDoc = new XmlDocument();
    reDoc.Load(stm);

    return reDoc.ToXDocument();
    }
    }
    }

  • 相关阅读:
    作业作业
    Alpha 冲刺 (4/10)
    Alpha 冲刺 (3/10)
    Alpha 冲刺 (2/10)
    Alpha 冲刺 (1/10)
    项目需求分析评审表
    项目需求分析答辩总结
    项目选题报告答辩总结
    UML
    各组项目答辩评分与存在问题
  • 原文地址:https://www.cnblogs.com/cotty/p/2321872.html
Copyright © 2011-2022 走看看