Unable to create Data connection to a List on a specific site
We recently worked on a quite interesting behavior where one of our customer was trying to create data connection to a list in a site collection and it used to fail with message "Unable to connect to the SharePoint site"
The issue behavior was specific to one single site collection level.
During our troubleshooting we used Fiddler Trace while creating the data connection and saw that InfoPath makes a call to the lists.asmx and the lists.asmx web service successfully returns all the list and library from that site collection
Post that it tries to call the webs.asmx and in the non working site collection instead of going to the root sites _vti/_bin/webs.asmx it was considering the managed path Sites as the root site and was constantly making call to sites/_vti/_bin/webs.asmx.
We also noticed another strange difference between working site collection and non working site collection.
In the non-working site collection when the web service lists.asmx returns the list and libraries in XML Format, the web view under the Fiddler was blank
Whereas the working site collection showed the web view for the xml returned by the lists.asmx successfully.
We tried to save the non working site collection lists.asmx result as XML file and when we tried to view in IE. Still the IE showed up blank.
So there was surely something wrong in the XML output
We used another great tool XML Notepad 2007 download from https://www.microsoft.com/en-in/download/details.aspx?id=7973
When we pasted the XML content inside the above tool, it clearly reported that the xml contained invalid characters.
So was our goal was identify the invalid character from the XML nodes
We started deleting each node and when we deleted one such node, the error was gone!
We found that the node was a library and in the library there was Description field which had some invalid characters
Once we deleted the description from the library settings, the lists.asmx returned the xml output which started showing successful web view in the fiddler
And InfoPath was able to create the data connection successfully.