views:

58

answers:

0

Amongst other things, our software connects to an online store. Part of the process downloads a catalogue of the products to preview in the software. Some of our users are having problems using the store and this seems to stem from this error in the logs:

System.InvalidOperationException: There is an error in XML document (2, 2). ---> System.InvalidOperationException: <html xmlns=''> was not expected.
at 
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCategoryInfo.Read4_Category()

The catalogue is deserialized from xml, here is a sample/format:

<?xml version="1.0"?>
<Category xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <Id>1</Id>
  <Name>Root</Name>
  <ParentCategoryId>-1</ParentCategoryId>
  <StoryList />
  <ChildCategoryList />
</Category>

In the actual data, there are stories and catergories in the respective lists.

The code to get the xml data is:

var request = HttpWebRequest.Create(_onlineStore + string.Format("integration/category/catalogue.ashx?username={0}&password={1}", HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(password))) as HttpWebRequest;
request.Method = "GET";
using (var response = request.GetResponse() as HttpWebResponse)
{
    var serializer = new XmlSerializer(typeof(CategoryInfo));
    CategoryInfo rtnVal = serializer.Deserialize(response.GetResponseStream()) as CategoryInfo;
    return rtnVal;
}

And the CategoryInfo class:

[Serializable]
[XmlRoot("Category")]
public class CategoryInfo
{
    public CategoryInfo()
    {
        ChildCategoryList = new List<CategoryInfo>();
        StoryList = new List<StoryInfo>();
    }

    public int Id
    {
        get;
        set;
    }

    public string Name
    {
        get;
        set;
    }

    public int ParentCategoryId
    {
        get;
        set;
    }

    [XmlArrayItem("Category")]
    public List<CategoryInfo> ChildCategoryList
    {
        get;
        set;
    }

    [XmlArrayItem("Story")]
    public List<StoryInfo> StoryList
    {
        get;
        set;
    }
}

The important thing here is that it is working for the vast majority. I could be wrong and there could be a horrible fault in the code and it's only working for most people by fluke, but I suspect the problem lies with the users computer or network connection.

One common problem we've had is getting around the proxy and/or firewalls that our customers have to use. Again the majority have to use one and the catalogue download and the program in general works for them.

Unless anyone can spot something wrong in the code or xml format, the answers I'm really looking for are reasons why this might happen to a minority of users and how best I can debug this without access to the users computer or particularly tech-savvy users with a lot of time on their hands.