Hi :)
I'm having some major trouble with an XML Client/Server application that I
am writing. I am using NetworkStream with CryptoStream to Read and Write
XML between computers. Now, whenever I write the XML, the Server section
which uses the XMLTextReader Class will not accept EndElements period, and
neither the ReadStartElement or ReadEndElement will work properly. However,
if I only send to WriteStartElements over the network, the Server will
receive it fine if I only use the Read Method. It will not accept
EndElements period. Since this application is just a test application, I'm
running it all on the same computer multi-threaded. If this is the problem,
please tell me so. I don't think it is, however, becuase if I just send
XMLStartElements, it reads those just fine with the XML.Read method no
matter how many start elements I send. I'm sure there's a very easy fix to
this, but, just in case, I have attached some of the more pertinent code
segments for your review. I didn't include the Listener section and the
Connect section because both of those work fine. Any help that anybody could
provide would be greatly appreciated. Thank you for your time.
Server App::
Button3.Text = "Waiting..."
Button3.ForeColor = Color.DarkRed
Dim ConnectedStream As Net.Sockets.NetworkStream
ConnectedStream = Server_Client.GetStream
Dim XMLDoc As New Xml.XmlDocument()
Dim CryptoReadStream As New Security.Cryptography.CryptoStream _
(ConnectedStream, _
EncProvider.CreateDecryptor(EncProvider.Key, EncProvider.IV), _
Security.Cryptography.CryptoStreamMode.Read)
Dim XMLRead As New Xml.XmlTextReader(CryptoReadStream)
XMLRead.WhitespaceHandling = Xml.WhitespaceHandling.None
Do While 1
XMLRead.Read()
Loop
Client App::
Dim ConnectedStream As Net.Sockets.NetworkStream
ConnectedStream = Client_Client.GetStream
Dim CryptoWriteStream As New Security.Cryptography.CryptoStream _
(ConnectedStream, _
EncProvider.CreateEncryptor(EncProvider.Key, EncProvider.IV), _
Security.Cryptography.CryptoStreamMode.Write)
Dim XMLWrite As New Xml.XmlTextWriter(CryptoWriteStream,
System.Text.Encoding.Default)
Button4.Text = "Sending..."
Button4.ForeColor = Color.DarkRed
XMLWrite.WriteStartElement("Start1")
XMLWrite.WriteEndElement()
XMLWrite.WriteStartElement("Start2")
XMLWrite.WriteEndElement()
XMLWrite.Flush()
XMLWrite.Close()
Button4.Text = "Message Sent!"
Button4.ForeColor = Color.DarkGreen
Thank you so much!!!
If you can help me out at all, I would surely appreciate it.
-- Casey J. Watson 1 4737
Not sure that this is exactly the problem, and the only problem.
In you example you are sending not well-formed document but document
fragment:
<Start1><Start1/>
<Start2><Start2/>
To change this you can wrap your fragment into additional element:
XMLWrite.WriteStartElement("root")
XMLWrite.WriteStartElement("Start1")
XMLWrite.WriteEndElement()
XMLWrite.WriteStartElement("Start2")
XMLWrite.WriteEndElement()
XMLWrite.WriteEndElement()
Sergey
"Casey Watson" <dy*****@collegeclub.com> wrote in message
news:#6**************@TK2MSFTNGP12.phx.gbl... Hi :)
I'm having some major trouble with an XML Client/Server application that I am writing. I am using NetworkStream with CryptoStream to Read and Write XML between computers. Now, whenever I write the XML, the Server section which uses the XMLTextReader Class will not accept EndElements period, and neither the ReadStartElement or ReadEndElement will work properly.
However, if I only send to WriteStartElements over the network, the Server will receive it fine if I only use the Read Method. It will not accept EndElements period. Since this application is just a test application,
I'm running it all on the same computer multi-threaded. If this is the
problem, please tell me so. I don't think it is, however, becuase if I just send XMLStartElements, it reads those just fine with the XML.Read method no matter how many start elements I send. I'm sure there's a very easy fix
to this, but, just in case, I have attached some of the more pertinent code segments for your review. I didn't include the Listener section and the Connect section because both of those work fine. Any help that anybody
could provide would be greatly appreciated. Thank you for your time.
Server App::
Button3.Text = "Waiting..."
Button3.ForeColor = Color.DarkRed
Dim ConnectedStream As Net.Sockets.NetworkStream
ConnectedStream = Server_Client.GetStream
Dim XMLDoc As New Xml.XmlDocument()
Dim CryptoReadStream As New Security.Cryptography.CryptoStream _
(ConnectedStream, _
EncProvider.CreateDecryptor(EncProvider.Key, EncProvider.IV), _
Security.Cryptography.CryptoStreamMode.Read)
Dim XMLRead As New Xml.XmlTextReader(CryptoReadStream)
XMLRead.WhitespaceHandling = Xml.WhitespaceHandling.None
Do While 1
XMLRead.Read()
Loop Client App::
Dim ConnectedStream As Net.Sockets.NetworkStream
ConnectedStream = Client_Client.GetStream
Dim CryptoWriteStream As New Security.Cryptography.CryptoStream _
(ConnectedStream, _
EncProvider.CreateEncryptor(EncProvider.Key, EncProvider.IV), _
Security.Cryptography.CryptoStreamMode.Write)
Dim XMLWrite As New Xml.XmlTextWriter(CryptoWriteStream, System.Text.Encoding.Default)
Button4.Text = "Sending..."
Button4.ForeColor = Color.DarkRed
XMLWrite.WriteStartElement("Start1")
XMLWrite.WriteEndElement()
XMLWrite.WriteStartElement("Start2")
XMLWrite.WriteEndElement()
XMLWrite.Flush()
XMLWrite.Close()
Button4.Text = "Message Sent!"
Button4.ForeColor = Color.DarkGreen
Thank you so much!!! If you can help me out at all, I would surely appreciate it.
-- Casey J. Watson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stingray |
last post by:
Are there any know problems with using a MemoryStream as a backing store for
a CryptoStream? I'm trying to simply encrypt and decrypt text in memory.
I'd like to create some simple methods to...
|
by: Stelrad Doulton |
last post by:
Hi all,
I am writting a Jabber-esque client-server application and have run into an
issue with the XmlTextReader constructor when passing a NetworkStream - It
hangs forever, apparently this is...
|
by: MattP |
last post by:
Ok, with the help of some examples found on the web and some minor
modifications on our own, we have a simple and working encrypt and
decrypt solution. It runs as a service, watches for files with...
|
by: weixiang |
last post by:
Hi,
I want to use DES and CryptoStream to serialize a encrypted stream to a file
with a header "CRYPT". And I wrote these code:
To store:
FileStream fileStream = new FileStream(fileName,...
|
by: Borgbjerg |
last post by:
I've got a multi-threaded server (we are very early in the project,
trying to uncover some risks), and I want to send data using XML.
The class ServerAdapter is supposed to connect to the server...
|
by: James |
last post by:
Hi,
I am developing a ActiveX Control which will be used in a web page.
The control will encrypt some value then decrypt it when the web page opens
next time.
I tested the control in a windows...
|
by: pesso |
last post by:
I have the following code that's taken and modified from a got_dot_net
example.
I'm trying to decrypt an Xml file that's been encrypted. I can dump the
decrypted stream to the console, but if I...
|
by: Nicholas Holder |
last post by:
A client creates a connection to the server using the TCPListener/Client
classes and transfers data via a NetworkStream. When the client connects,
the server creates a process and redirects its...
|
by: g66g08d14 |
last post by:
Hi.
We have a Jabber-esque client server package that uses XMPP for
communication over network sockets.
Using .NET 2.0, I need to read a full stanza (i.e. balanced xml) as
soon as available...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |