By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,183 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,183 IT Pros & Developers. It's quick & easy.

Serializing a System.Exception using SOAP generates invalid XML

P: n/a
I try to serialize an exception using the SoapFormatter, but this is a little
bit problematic. The MethodInfo tag of the serialized exception contains &x00
characters (ASCII 0x00) in its serialized data. When the data is deserialized
on the client side the SoapHttpClientProtocol.ReadResponse uses an
XmlTextReader with Normalization switched on. In that case the &x00 character
is not valid and results in the following XmlException:

System.Xml.XmlException: '\0', hexadecimal value 0x00, is an invalid
character. Line 1, position 398.
at System.Xml.XmlScanner.ScanHexEntity()
at System.Xml.XmlTextReader.ParseBeginTagExpandCharEn tities()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlLoader.LoadChildren(XmlNode parent)
at System.Xml.XmlLoader.LoadElementNode()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.ReadCurrentNode(XmlDocument doc, XmlReader reader)
at System.Xml.XmlDocument.ReadNode(XmlReader reader)
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadSoapException(XmlReader reader)
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)

I don't know think that the actual problem is that the SOAP message parsing
uses a normalized reader, but the MethodInfo is serialized using '\0' as
seperators. I checked the serialization using the .NET Reflector tool and it
System.Exception is using this character on purpose. It is a bit weird that
the SoapFormatter can create serialized XML data that cannot be parsed on the
client side.

I can solve this problem by using a binary serialization and store the
BASE-64 data in the detail node, but this makes my SOAP messages less
readable. I really liked the idea to serialize exceptions via the Detail node
(I regenerate them on the client). I use a workaround right now, but I am not
quite happy with it. Can anyone comment to this issue?

--
Greetings,
Ramon de Klein
Nov 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.