views:

237

answers:

1

Hi everyone,

I am trying to access this webservice, The problem is that sometimes XDocument.Parse is not able to process and generates an error System.Xml.XmlException: Root element is missing. on the line:

XDocument xmlDoc = XDocument.Parse(xmlData);

Even though the XML sent is correct according to my logs.

I was wondering, Is it possible that the StreamReader is not working properly

    using (StreamReader reader = new StreamReader(context.Request.InputStream))
    {
        xmlData = reader.ReadToEnd();
    }

    XDocument xmlDoc = XDocument.Parse(xmlData);

By the way this is all under a Custom HttpHandler.

Can someone please me guide in the right direction for this.

Thanks

+1  A: 

Does it work any more consistently if you use

XDocument.Load(new StreamReader(context.Request.InputStream))

instead of XDocument.Parse?

Brandon