I had an InfoPath web form configured, working well, and ready to deploy. I let my colleague know about it and when he tried it out a day or two later, he was getting an error message I hadn’t myself seen:
There has been an error while processing the form.
Click Continue to resume filling out the form. You may want to check your form data for errors.
Click Start Over to load a new copy of the form.
Show error details
When I browsed the Details of the error message, InfoPath Forms Services showed me this:
An error occurred accessing a data source.
An entry has been added to the Windows event log of the server.
Log ID: 5566
Not much help there, but I kept trying to figure this out. I tried from different browsers (same error) and from different PCs (still same).
I got the bright idea to check the settings in the Data Connection in the InfoPath template I’d designed, but everything looked the same – even the URL that I was using to retrieve an XML representation of the List data (according to this helpful blog entry on “Accessing SharePoint List Data as XML” and “Populating form data from SharePoint List Views”). However, when I tried completing the Data Connection wizard for this existing connection, I was getting blasted with this error:
The file is not a valid XML file.
The file is not a valid XML document.
A document must contain exactly one root element.
Line 1, Position 0
I wondered if I’d messed up the permissions on the List, so I verified that I and my colleague had Read & Contribute permissions (so the Form would load), and I even added back the “System Account” with its Limited Access (using the “trick” documented in this blog article). Still nothing.
When I tried to load that URL in a browser, the page it returned was blank, and even when I looked at the View Source, there wasn’t anything helpful there:
I retried this over and over for a few days, re-examining the URL in the Data Connection, triple-checking the GUIDs (thinking they must’ve gotten changed somehow during a recent tweak to the List), and wondering what I’d done wrong (or what had gotten horked up on the servers).
And the Solution Is…
Eventually I tried some googling on “A document must contain exactly one root element”, and finally returned to my old friends, the InfoPathDev.com and SharePointBlogs.com sites. When I arrived back at the “Accessing SharePoint List Data as XML” article, one of the comments jumped out at me:
I can’t get this to work on a List that contains a Lookup field. I just get a blank page in the browser. Have you encountered this too? Any ideas?
Bingo! One of the recent tweaks I’d made was to convert a field in the list from using the “Choice” data type to the “Lookup” data type. (Note: using a Lookup to a separate List enables me to delegate maintenance of that list of Choices to my team members, without asking them to muddle around in the bowels of my List’s Column settings.)
All I had to do was to remove the one Lookup field from the View I was retrieving in this Data Connection, and the web Form started working again (without any changes or re-Publishing necessary, even!). I even confirmed that the URL, when used in a browser, would return a readable XML document (though you have to View Source on the returned page, which looks just as blank in IE8 as the failing one).
Lesson: if you’re going to leverage SharePoint Lists as XML data sources in your InfoPath Forms, make sure that the View you select does NOT include a Lookup field. I told you this was obscure…