3 July 2014

SPIF error when synchronising documents


In a recent project, we had a Sitecore/Sharepoint integration task. After looking at the different options, we have decided to use the SPIF. Looking at the documentation, that would definitely do what we needed and provided even more API possibilities.

So we started the implementation and everything looked quite nice:
  • Connecting to the Sharepoint server
  • Create the Sharepoint connector item in Sitecore
  • And even retrieving the documents.
Unfortunately, we encountered an error:

For one of the library we were trying to sync, none of the document were getting into sitecore. After looking at the log file  we had the following exception:

ManagedPoolThread #10 00:00:00 ERROR Sharepoint Provider can't process tree.
Integration config item ID: {23C8604D-6761-4FD8-B3AD-A0E3BB880AD8}, Web:http://sharepoint.test.com/ List: {7C8A645E-A085-46DE-A059-168B8F480641}
Exception: System.InvalidOperationException
Message: There is an error in XML document (44, 2760).
Source: System.Xml
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Sitecore.Sharepoint.Data.WebServices.SharepointLists.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID)
   at Sitecore.Sharepoint.ObjectModel.Connectors.ItemCollectionConnector.GetItems(BaseList list, ItemsRetrievingOptions options)
   at Sitecore.Sharepoint.ObjectModel.Entities.Collections.ItemCollection.GetEntities()
   at Sitecore.Sharepoint.Data.Providers.SharepointProvider.ProcessTree(ProcessIntegrationItemsOptions processIntegrationItemsOptions, SynchContext synchContext)
   at Sitecore.Sharepoint.Data.Providers.SharepointProvider.ProcessTree(ProcessIntegrationItemsOptions processIntegrationItemsOptions, Item integrationConfigDataSource)
 
Nested Exception
 
Exception: System.Xml.XmlException
Message: '[1]', hexadecimal value 0x02, is an invalid character. Line 44, position 2760.
Source: System.Xml
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, StringBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType)
   at System.Xml.XmlTextReaderImpl.ParseNumericCharRef(Boolean expand, StringBuilder internalSubsetBuilder, EntityType& entityType)
   at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
   at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
   at System.Xml.XmlTextReaderImpl.ParseAttributes()
   at System.Xml.XmlTextReaderImpl.ParseElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.ReadCurrentNode(XmlDocument doc, XmlReader reader)
   at System.Xml.XmlDocument.ReadNode(XmlReader reader)
   at System.Xml.Serialization.XmlSerializationReader.ReadXmlNode(Boolean wrapped)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLists.Read30_GetListItemsResponse()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer53.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

That kept us going for days. Sitecore support and Sitecore team help us debugging the issue and provided us with a fix. Basically what happen is, there are some invalid chars (for XML parsing) on the documents we are trying to retrieve from Sharepoint. This was causing the XML parsing to fail and none of the documents were getting created in Sitecore. You can find the issue with the resolution in the knowledge base item.

Solution: 1- download the dll patch from the knowledge base item 2- Modify the web.config file by adding the following configuration into the < system.web> section:
< webservices> 
  < soapextensiontypes> 
    < add group="0" priority="1" type="Sitecore.Support.SharePoint.XmlCleanupSoapExtension, Sitecore.Support.411647" /> 
  < /soapextensiontypes> 
< /webservices>

No comments:

Post a Comment