J
jwallison
TcpClient client = new TcpClient(AddressFamily.InterNetwork);
client.SendTimeout = mSvcConfig.Data.SvcTimeout; // 1000
client.Connect( mSvcConfig.Data.SvcAddress, mSvcConfig.Data.SvcPort);
//"localhost", 7024
NetworkStream stream = client.GetStream();
XmlSerializer outserializer = new XmlSerializer(typeof(LinkMessage));
//my data object, all string/int data
XmlTextWriter tw = new XmlTextWriter( stream, Encoding.UTF8);
outserializer.Serialize(tw, mMsg ); // ref to my LinkMessage data
instance
stream.Flush();
client.Close();
Produces the following output when written via the TcpClient stream (note
extraneous "o;?" at beginning of message):
o;?<?xml version="1.0" encoding="utf-8"?><LinkMessage
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><MessageType>Anchor</M
essageType><InnerText>Client Side ImageMap</InnerText><Href>http:
//www.he.net/~seidel/Map/clientmap.html</Href><ImageSrc /></LinkMessage>
but produces the same output, sans garbage, when the same code writes to an
XmlTextWriter based on a disk file (i.e. - seems like changing only the
stream type results in spurious "added" output) on a NetwrokStream.
If the encoding is changed to Encoding.Unicode, different garbage (¦~) prior
to the actual message.
If Encoding.ASCII, no garbage - but also wrong encoding in the emitted XML.
What can I do to eliminate this leading junk at the beginning of my
messages? The Java app that is a target for this socket communication can't
handle it...
TIA
--
Regards,
Jim Allison
(e-mail address removed)
(de-mung by removing '.1')
(e-mail address removed)
client.SendTimeout = mSvcConfig.Data.SvcTimeout; // 1000
client.Connect( mSvcConfig.Data.SvcAddress, mSvcConfig.Data.SvcPort);
//"localhost", 7024
NetworkStream stream = client.GetStream();
XmlSerializer outserializer = new XmlSerializer(typeof(LinkMessage));
//my data object, all string/int data
XmlTextWriter tw = new XmlTextWriter( stream, Encoding.UTF8);
outserializer.Serialize(tw, mMsg ); // ref to my LinkMessage data
instance
stream.Flush();
client.Close();
Produces the following output when written via the TcpClient stream (note
extraneous "o;?" at beginning of message):
o;?<?xml version="1.0" encoding="utf-8"?><LinkMessage
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><MessageType>Anchor</M
essageType><InnerText>Client Side ImageMap</InnerText><Href>http:
//www.he.net/~seidel/Map/clientmap.html</Href><ImageSrc /></LinkMessage>
but produces the same output, sans garbage, when the same code writes to an
XmlTextWriter based on a disk file (i.e. - seems like changing only the
stream type results in spurious "added" output) on a NetwrokStream.
If the encoding is changed to Encoding.Unicode, different garbage (¦~) prior
to the actual message.
If Encoding.ASCII, no garbage - but also wrong encoding in the emitted XML.
What can I do to eliminate this leading junk at the beginning of my
messages? The Java app that is a target for this socket communication can't
handle it...
TIA
--
Regards,
Jim Allison
(e-mail address removed)
(de-mung by removing '.1')
(e-mail address removed)