Send XML via HTTP Post to IP:Port

后端 未结 2 793
鱼传尺愫
鱼传尺愫 2021-02-10 12:03

Ok so to start off, I\'m not using any sort of web service. Right now I don\'t know a whole lot about the application receiving the XML other than it receives it. Big help there

相关标签:
2条回答
  • 2021-02-10 12:29

    The recommended way to make simple web requests is to use the WebClient object.

    Here's a code snippet:

    // assume your XML string is returned from GetXmlString()
    string xml = GetXmlString();
    
    
    // assume port 8080
    string url = new UriBuilder("http","www.example.com",8080).ToString();     
    
    
    // create a client object
    using(System.Net.WebClient client = new System.Net.WebClient()) {
        // performs an HTTP POST
        client.UploadString(url, xml);  
    
    }
    
    0 讨论(0)
  • 2021-02-10 12:33

    If you have an IP and port why you are not trying XML over TCP/IP. In C# you can do this by using System.Net.Sockets class TCPClient. This class is having methods Connect , send and receive, in order to connect with IP and port then send message and wait to receive message.

    0 讨论(0)
提交回复
热议问题