Send XML via HTTP message to IP address:

So, to get started, I am not using any kind of web service. Right now I don’t know much about an application that receives XML, other than getting it. Great help there I know. I did not write the recipient application, but my company has no useful ways to test the XML transfer phase.

I basically want to send an XML document like this ...

<H2HXmlRequest class="myClass">
<Call>
    <CallerID></CallerID>
    <Duration>0</Duration>
</Call>
<Terminal>
    <CancelDate></CancelDate>
    <ClerkLoginTime></ClerkLoginTime>
</Terminal>
<Transaction>
    <AcceptedCurrency></AcceptedCurrency>
    <AccountId>6208700003</AccountId>
</Transaction>
</H2HXmlRequest>

... to an application that I really don't know much about. It was not invented, and with the proper help, I could find out more information. But what I want to do is come up with some kind of C # Forms application that can accept this request above, send it using IP and port and hopefully see something.

+5
2

- WebClient.

:

// 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);  

}
+10

IP , XML TCP/IP. # , System.Net.Sockets TCPClient. Connect, send receive, IP , , .

0

All Articles