%3CLINGO-SUB%20id%3D%22lingo-sub-509650%22%20slang%3D%22en-US%22%3EHow%20to%20use%20CMIS%20APIs%20to%20extract%20information%20from%20SharePoint%20repositories%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-509650%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20May%2018%2C%202012%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1272120088%22%20id%3D%22toc-hId--1272120088%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1215392745%22%20id%3D%22toc-hId-1215392745%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--592061718%22%20id%3D%22toc-hId--592061718%22%3EWhat%E2%80%99s%20CMIS%20Connector%20for%20SharePoint%202010%3F%3C%2FH2%3E%0A%3CP%3EThis%20post%20is%20a%20contribution%20from%20Chanchal%20Jain%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team.%3C%2FP%3E%0A%3CP%3EContent%20Management%20Interoperability%20Services%20(CMIS)%20connector%20for%20Microsoft%20SharePoint%20Server%202010%20enables%20SharePoint%20users%20to%20interact%20with%20content%20that%20is%20stored%20in%20any%20repository%20that%20has%20implemented%20the%20CMIS%20standard.%20The%20connector%20also%20makes%20SharePoint%20Server%202010%20content%20available%20to%20any%20application%20that%20has%20implemented%20the%20CMIS%20standard.%20The%20CMIS%20connector%20is%20available%20as%20part%20of%20the%20SharePoint%202010%20Administration%20Toolkit.%3C%2FP%3E%0A%3CP%3EFor%20more%20details%2C%20refer%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Flibrary%2Fff934619.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Content%20Management%20Interoperability%20Services%20(CMIS)%20connector%20overview%20(SharePoint%20Server%202010)%20%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fdisplaylang%3Den%26amp%3Bid%3D20022%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Microsoft%20SharePoint%202010%20Administration%20Toolkit%20v2.0%20%3C%2FA%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1895451115%22%20id%3D%22toc-hId-1895451115%22%3EHow%20to%20use%20CMIS%20APIs%20to%20extract%20information%20from%20SharePoint%20repositories%3F%3C%2FH2%3E%0A%3CP%3EOnce%20the%20CMIS%20connector%20is%20installed%20on%20the%20SharePoint%20Server%2C%20it%20exposes%20a%20set%20of%20WCF%20Services%20to%20perform%20read%2Fwrite%20and%20various%20operations%20on%20the%20repositories%20(maps%20to%20SharePoint%20list%20and%20libraries).%3C%2FP%3E%0A%3CP%3EThe%20set%20of%20mapping%20is%20available%20at%20%3CA%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Flibrary%2Fff934619.aspx%23section5%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Mapping%20the%20CMIS%20data%20model%20to%20SharePoint%20concepts%20%3C%2FA%3E%20.%3C%2FP%3E%0A%3CP%3EI%20used%20the%20Discovery%20Service%20%26lt%3B%26gt%3B%2F_vti_bin%2FCMIS%2Fsoap%2FdiscoveryService.svc%20%26gt%3B%20exposed%20by%20the%20CMIS%20Connector%20to%20read%20information%20from%20the%20SharePoint%20list.%3C%2FP%3E%0A%3CP%3EThe%20sample%20code%20after%20adding%20a%20Service%20reference%20in%20my%20project%20to%20get%20information%20from%20the%20Repository%20(translated%20to%20SharePoint%20List%20%26amp%3B%20Document%20Library)%20is%20as%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22codeSnippetWrapper%22%3E%0A%3CDIV%20id%3D%22codeSnippet%22%3E1%3A%20string%20RepositoryID%20%3D%20%22c4e0c77c-16ad-48d2-8a1e-0747af0d3b08%22%3B%20%2F%2FThe%20List%20ID%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E2%3A%20string%20keyword%20%3D%20%22Microsoft%22%3B%20%2F%2FKeyword%20to%20be%20searched%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E3%3A%20string%20filePath%20%3D%20%22C%3A%5CTempFolder%5CQueryResponse.xml%22%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E4%3A%20DiscoveryServicePortClient%20DiscoveryClient%20%3D%20null%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E5%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E6%3A%20DiscoveryClient%20%3D%20new%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E7%3A%20DiscoveryServicePortClient(%22BasicHttpBinding_IDiscoveryServicePort%22)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E8%3A%20DiscoveryClient.ClientCredentials.Windows.AllowedImpersonationLevel%20%3D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E9%3A%20System.Security.Principal.TokenImpersonationLevel.Impersonation%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E10%3A%20DiscoveryClient.ClientCredentials.Windows.ClientCredential%20%3D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E11%3A%20CredentialCache.DefaultNetworkCredentials%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E12%3A%20DiscoveryClient.ClientCredentials.Windows.AllowNtlm%20%3D%20true%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E13%3A%20DiscoveryClient.Open()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E14%3A%20cmisExtensionType%20DisCMISExtType%20%3D%20new%20cmisExtensionType()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E15%3A%20string%20query%20%3D%20%22SELECT%20cmis%3AobjectId%2C%20cmis%3Aname%20FROM%20cmis%3Adocument%20where%20CONTAINS('%22%20%2B%20keyword%2B%20%22')%20%22%3B%2F%2FCMIS%20Query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E16%3A%20cmisObjectListType%20resultQuery%20%3D%20DiscoveryClient.query(RepositoryID%2C%20query%2C%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E17%3A%20true%2C%20true%2C%20enumIncludeRelationships.none%2C%20%22%22%2C%20%22255%22%2C%20%220%22%2C%20DisCMISExtType%2C%20null)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E18%3A%20Stream%20streamWrite%20%3D%20File.Create(filePath)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E19%3A%20XmlSerializer%20soapWrite%20%3D%20new%20XmlSerializer(typeof(cmisObjectListType))%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E20%3A%20soapWrite.Serialize(streamWrite%2C%20resultQuery)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E21%3A%20streamWrite.Close()%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-509650%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20May%2018%2C%202012%20What%E2%80%99s%20CMIS%20Connector%20for%20SharePoint%202010%3F%20This%20post%20is%20a%20contribution%20from%20Chanchal%20Jain%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-509650%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on TECHNET on May 18, 2012

 

 

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();