B
Bob Garbados
I need to construct an xml document, send it to a service over tcp/ip to a
specified port, receive the xml response, and process the xml response. I
can create the xml document to send, but what's the best way to move the
data from an XmlDocument to a Byte array? Currently I paste the xml into a
textbox and send it with the following code:
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect("127.0.0.1", 10000)
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim strXml As String
strXml = txtXmlInput.Text.ToString
Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(strXml)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim strXml As String
strXml = txtXmlInput.Text.ToString
Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(strXml)
networkStream.Write(sendBytes, 0, sendBytes.Length)
I can get the returned xml stream into a string, but how would I get the
returned byte array into an XmlDocument? Here's how I currently get the
returned stream into a string:
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
NetworkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Thanks.
specified port, receive the xml response, and process the xml response. I
can create the xml document to send, but what's the best way to move the
data from an XmlDocument to a Byte array? Currently I paste the xml into a
textbox and send it with the following code:
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect("127.0.0.1", 10000)
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim strXml As String
strXml = txtXmlInput.Text.ToString
Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(strXml)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim strXml As String
strXml = txtXmlInput.Text.ToString
Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(strXml)
networkStream.Write(sendBytes, 0, sendBytes.Length)
I can get the returned xml stream into a string, but how would I get the
returned byte array into an XmlDocument? Here's how I currently get the
returned stream into a string:
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
NetworkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Thanks.