Hello, I want to send an XML through a TCP message in c#.
I need to know how to create the XML in the format that I leave you, how to send it to a host and port and then take the XML response that the host returns.
Here is an example of the XML format.
POST xml.xml HTTP/1.1
Content-Type: application/xml
Content-Length: 280
<?xml version="1.0" encoding="ISO-8859-1" ?>
<NODO1>
<PARAM1>VALOR1</PARAM1>
<PARAM2>VALOR2</PARAM2>
<PARAM3>VALOR3</PARAM3>
<PARAM4>VALOR4</PARAM4>
<PARAM5>VALOR5</PARAM5>
<PARAM6>VALOR6</PARAM6>
<PARAM7>VALOR7</PARAM7>
<PARAM8>VALOR8</PARAM8>
</NODO1>
Thanks in advance.
Solution to the error:
writer.AutoFlush = false;
writer.Write("POST xml.xml HTTP/1.1");
writer.Write("\r\n");
writer.Write("Content-Type: application/xml");
writer.Write("\r\n");
writer.Write("Content-Length: ");
writer.Write(encoding.GetBytes(message).Length);
writer.Write("\r\n");
writer.Write("\r\n");
writer.Write(message);
writer.Write("\r\n");
writer.Write("\r\n");
writer.Flush();
StreamReader reader = new StreamReader(stream, encoding);
while (reader.Peek() >= 0)
{
response += reader.ReadLine();
}
Greetings.
I hope this code helps you.