i have a request that requires the use of a 2-byte header for an SSL transaction. i posted below the requirement and the code snippet where the 2-byte header designation would go. if anyone can offer any assistance into this, it would be greatly appreciated. thanks in advance. here is spec for using the 2-byte header:
for TCP/IP communications, these XML messages should be preceeded by a two-byte header that simply contians a two-binary byte length that indicates the total length of the XML message, plus two bytes for the length itself. the two-byte header should be in network byte order (most significant byte first).
For example, if the XML message (including tags, CR LF vlaues, and patload was 500 bytes, place 502 binary (oxo1 oxF6) a two-byte header in the first 2 bytes of the TCP/IP send buffer, followed by all 500 bytes of the XML message...
here is my code:
string payload = "*0210000001.0950003946614.MZ2003000.100340620000.5499992345678903.0908.106.0.aY.30329 4 CORPORATE SQ.....00.";
string xmlPackage = "<BinaryMsgReq>\r\n<Version>2.0</Version>\r\n<MsgSet>TEXT-EAST</MsgSet>\r\n<ProcessMode>CERT1</ProcessMode>\r\n<ClientRefNumber>0</ClientRefNumber>\r\n<Payload>" + payload + "</Payload>\r\n</BinaryMsgReq>\r\n";
//need to create 2-byte header from message size
byte[] messsage = Encoding.UTF8.GetBytes(xmlPackage);
sslStream.Write(messsage);
sslStream.Flush();
string serverMessage = ReadMessage(sslStream);
client.Close();
for TCP/IP communications, these XML messages should be preceeded by a two-byte header that simply contians a two-binary byte length that indicates the total length of the XML message, plus two bytes for the length itself. the two-byte header should be in network byte order (most significant byte first).
For example, if the XML message (including tags, CR LF vlaues, and patload was 500 bytes, place 502 binary (oxo1 oxF6) a two-byte header in the first 2 bytes of the TCP/IP send buffer, followed by all 500 bytes of the XML message...
here is my code:
string payload = "*0210000001.0950003946614.MZ2003000.100340620000.5499992345678903.0908.106.0.aY.30329 4 CORPORATE SQ.....00.";
string xmlPackage = "<BinaryMsgReq>\r\n<Version>2.0</Version>\r\n<MsgSet>TEXT-EAST</MsgSet>\r\n<ProcessMode>CERT1</ProcessMode>\r\n<ClientRefNumber>0</ClientRefNumber>\r\n<Payload>" + payload + "</Payload>\r\n</BinaryMsgReq>\r\n";
//need to create 2-byte header from message size
byte[] messsage = Encoding.UTF8.GetBytes(xmlPackage);
sslStream.Write(messsage);
sslStream.Flush();
string serverMessage = ReadMessage(sslStream);
client.Close();