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();
    }
    }
    }

  • 相关阅读:
    最简单的jQuery插件
    SQL执行时间
    Resharper 8.2 注册码
    Module模式
    RestSharp使用
    使用MVC过滤器保存操作日志
    Ajax Post 类实例
    IBatis分页显示
    IBatis插入类的实例
    Topcoder SRM629 DIV2 解题报告
  • 原文地址:https://www.cnblogs.com/cotty/p/2321872.html
Copyright © 2011-2022 走看看