I am seeing a quite intermittent problem in a system where calls to a .NET
web service throws the exception below:
System.Xml.XmlException: Data at the root level is invalid. Line 1, position
1.
The call is never logged anywhere on the server and the next call goes
through without any problems. Not all of our environmenst see this, just
some.
I have two questions in regards to this:
1. How can I simulate this behaviour on the server side so that the web
service returns malformed xml? So that I can on the client side take care of
the exception i a good way and test this.
2. How can I in the client, when the exception is caught, see what the
response is? I'd like to log it and see what is in there? I suspect it's an
error message from a router or from the IIS.
See stack trace below:
System.InvalidOperationException: Response is not well-formed XML. --->
System.Xml.XmlException: Data at the root level is invalid. Line 1, position
1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Microsoft.Web.Services.XmlSkipDTDReader.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Microsoft.Web.Services.SoapEnvelope.Load(Stream stream)
at Microsoft.Web.Services.InputStream.GetRawContent()
at Microsoft.Web.Services.InputStream.Read(Byte[] buffer, Int32 offset,
Int32 count)
at System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset,
Int32 desiredChars, Boolean& readToUserBuffer)
at System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
at System.Xml.XmlTextReaderImpl.ReadData()
at System.Xml.XmlTextReaderImpl.InitTextReaderInput(String baseUriStr,
TextReader input)
at System.Xml.XmlTextReaderImpl..ctor(String url, TextReader input,
XmlNameTable nt)
at System.Xml.XmlTextReader..ctor(TextReader input)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.GetReaderForMessage(SoapClientMessage
message, Int32 bufferSize)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
TIA,
Erik
Erik Alsmyr - 17 Aug 2007 11:57 GMT
Using .NET framework 2.0 on both client and serverside.
/Erik
>I am seeing a quite intermittent problem in a system where calls to a .NET
>web service throws the exception below:
[quoted text clipped - 57 lines]
> TIA,
> Erik