1

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

4

2 回答 2

1

如果你使用它会更一致地工作吗

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

而不是 XDocument.Parse?

于 2010-06-28T21:41:09.740 回答
0

您的代码示例不包括读取输入流的日志记录。问题在此之前。

于 2011-04-05T07:42:22.517 回答