Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2007

Tip: Looking for answers? Try searching our database.

Getting malformed XML from a web service interface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Erik Alsmyr - 17 Aug 2007 11:56 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.