title: How do I debug mangled soap requests?
body: <p>Lately, we've been seeing exceptions like this in our .NET (.asmx) webservices:</p>
  
  <pre><code>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (868, -3932). ---&gt; System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 868, position -3932.
     at System.Xml.XmlTextReaderImpl.Throw(Exception e)
     at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
     at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
     at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Int32 pos, Char invChar)
     at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, BufferBuilder internalSubsetBuilder, Int32&amp; charCount, EntityType&amp; entityType)
     at System.Xml.XmlTextReaderImpl.ParseText(Int32&amp; startPos, Int32&amp; endPos, Int32&amp; outOrChars)
     at System.Xml.XmlTextReaderImpl.ParseText()
     at System.Xml.XmlTextReaderImpl.ParseElementContent()
     at System.Xml.XmlTextReaderImpl.Read()
     at System.Xml.XmlTextReader.Read()
     at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()
     at System.Xml.XmlReader.ReadElementString()
     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read14_SendErrlog()
     at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer12.Deserialize(XmlSerializationReader reader)
     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
     --- End of inner exception stack trace ---
     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
     at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
     at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
     --- End of inner exception stack trace ---
     at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
     at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
  </code></pre>
  
  <p>How can I debug this exception? This exception is getting reported to us from a SOAP filter which looks for exceptions in message.Stage = SoapMessageStage.AfterSerialize.</p>
  
  <p>Is there any way to get at the original soap request? How do I get an invalid character at line 868, column -3932? How can there a <strong>negative</strong> column 3932?</p>