SharePoint Developer Support Team Blog

The Official blog of the SharePoint Developer Support Team

How to use CMIS APIs to extract information from SharePoint repositories?

How to use CMIS APIs to extract information from SharePoint repositories?

  • Comments 1
  • Likes

What’s CMIS Connector for SharePoint 2010?

This post is a contribution from Chanchal Jain, an engineer with the SharePoint Developer Support team.

Content Management Interoperability Services (CMIS) connector for Microsoft SharePoint Server 2010 enables SharePoint users to interact with content that is stored in any repository that has implemented the CMIS standard. The connector also makes SharePoint Server 2010 content available to any application that has implemented the CMIS standard. The CMIS connector is available as part of the SharePoint 2010 Administration Toolkit.

For more details, refer:

Content Management Interoperability Services (CMIS) connector overview (SharePoint Server 2010)

Microsoft SharePoint 2010 Administration Toolkit v2.0

How to use CMIS APIs to extract information from SharePoint repositories?

Once the CMIS connector is installed on the SharePoint Server, it exposes a set of WCF Services to perform read/write and various operations on the repositories (maps to SharePoint list and libraries).

The set of mapping is available at Mapping the CMIS data model to SharePoint concepts.

I used the Discovery Service <http://<Site url>/_vti_bin/CMIS/soap/discoveryService.svc > exposed by the CMIS Connector to read information from the SharePoint list.

The sample code after adding a Service reference in my project to get information from the Repository (translated to SharePoint List & Document Library) is as:

   1: string RepositoryID = "c4e0c77c-16ad-48d2-8a1e-0747af0d3b08"; //The List ID
   2: string keyword = "Microsoft"; //Keyword to be searched
   3: string filePath = "C:\TempFolder\QueryResponse.xml"; 
   4: DiscoveryServicePortClient DiscoveryClient = null;
   5:  
   6: DiscoveryClient = new 
   7: DiscoveryServicePortClient("BasicHttpBinding_IDiscoveryServicePort");                    
   8: DiscoveryClient.ClientCredentials.Windows.AllowedImpersonationLevel = 
   9: System.Security.Principal.TokenImpersonationLevel.Impersonation;
  10: DiscoveryClient.ClientCredentials.Windows.ClientCredential = 
  11: CredentialCache.DefaultNetworkCredentials;
  12: DiscoveryClient.ClientCredentials.Windows.AllowNtlm = true;
  13: DiscoveryClient.Open();
  14: cmisExtensionType DisCMISExtType = new cmisExtensionType();
  15: string query = "SELECT cmis:objectId, cmis:name FROM  cmis:document where CONTAINS('" + keyword+ "') ";//CMIS Query
  16: cmisObjectListType resultQuery = DiscoveryClient.query(RepositoryID, query,
  17: true, true, enumIncludeRelationships.none, "", "255", "0", DisCMISExtType, null);
  18: Stream streamWrite = File.Create(filePath);
  19: XmlSerializer soapWrite = new XmlSerializer(typeof(cmisObjectListType));
  20: soapWrite.Serialize(streamWrite, resultQuery);
  21: streamWrite.Close();
Comments
  • Does this work for sharepoint 2013 ? I was trying to do similar with sharepoint online 2013 site and was getting The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment