Share Point Object Model


Published on

This presentation is for explaining the basics of SharePoint Object Model/Web Services. These sessions are done online. Check more details @

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Share Point Object Model

  1. 1. Online Training on SharePoint 2007<br />Check Training Details @Training Details<br />Moss Experts<br /><br />
  2. 2. SharePoint Object Model, Web Services, Features and Solutions<br />Moss Experts<br /><br />
  3. 3. Features of SharePoint Object Model<br />SharePoint will use ASP.NET instead of ISAPI for base page execution<br />Server Object Model for programmatic access to SharePoint data<br />Exposing Data via XML web services for access from remote machines<br />Managed code object model on the server<br />Accessible via ASP.NET or any other server process<br />Exposes almost of all of the data stored in WSS<br />Implemented in C#<br />Add Microsoft.SharePointdll from Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPI<br /><br />
  4. 4. SharePoint Object Model<br />It gives us full access to SharePoint<br />Only available on the server<br /><br />
  5. 5. Examples of what can be done with the Object Model:<br />Add, edit, delete, and retrieve data from SharePoint Lists <br />Create new lists and set list metadata (e.g. the fields in a list) <br />Set web properties <br />Work with documents in document libraries. <br />Perform administrative tasks such as creating webs, adding users, creating roles, etc. <br />Pretty much any functionality in the UI can be automated through the OM!<br /><br />
  6. 6. Object Model Hierarchy<br /><br />
  7. 7. Microsoft.SharePoint.Administration : Provides administrative types and members for managing a Windows SharePoint Services deployment. <br /><br />
  8. 8. The SPFarm object is the highest object within the Windows SharePoint Services object model hierarchy. The Servers property gets a collection representing all the servers in the deployment, and the Services property gets a collection representing all the services.<br />Each SPServer object represents a physical server computer. The ServiceInstances property provides access to the set of individual service instances that run on the individual computer.<br />An SPWebService object provides access to configuration settings for a specific logical service or application. The WebApplications property gets the collection of Web applications that run the service.<br />An SPDatabaseServiceInstance object represents a single instance of a database service running on the server computer.<br />Each SPWebApplication object represents a load-balanced Web application based in Internet Information Services (IIS). The SPWebApplication object provides access to credentials and other server farm wide application settings. The Sites property gets the collection of site collections within the Web application, and the ContentDatabases property collection of content databases used in the Web application. <br />An SPContentDatabase object inherits from the SPDatabase class and represents a database that contains user data for a SharePoint Web application. <br />An SPSiteCollection object represents the collection of site collections within the Web application. <br /><br />
  9. 9. Microsoft.SharePoint: Provides types and members for working with a top-level site and its sub sites<br /><br />
  10. 10. Each SPSite object, represents a set of logically related SPWeb objects. Such a set is commonly called a &quot;site collection<br />Each site collection includes any number of SPWeb objects, and each object has members that can be used to manage a site, including its template and theme, as well as to access files and folders on the site. <br />Each SPList object has members that are used to manage the list or access items in the list. The GetItems method can be used to perform queries that return specific items. The Fields property returns an SPFieldCollection object that represents all the fields, or columns, in the list, and the Items property returns an SPListItemCollection object that represents all the items, or rows, in the list.<br />Each SPField object has members that contain settings for the field.<br />Each SPListItem object represents a single row in the list.<br /><br />
  11. 11. Example Objects<br />Security<br />SPGroup<br />SPGroupCollection<br />SPSite<br />SPUser<br />SPUserCollection<br />Documents<br />SPDocumentLibrary<br />SPFile<br />SPFileCollection<br />SPFolder<br />List Data<br />SPField<br />SPFieldCollection<br />SPListCollection<br />SPList<br />SPListItemCollection<br />SPListItem<br />SPView<br />Administration<br />SPGlobalAdmin<br />SPQuota<br />SPVirtualServer<br /><br />
  12. 12. Accessing Data in a MOSS List<br />Get a SPList or SPDocumentLibrary object.<br />SPListmylist = web.Lists[“Events”];<br />You can then call the .Items property to get all of the items:<br />SPListItemCollection items = mylist.Items;<br />If you only want a subset of the items, call the GetItems method and pass a SPQuery object<br />SPListItemCollection items = mylist.GetItems(query);<br /><br />
  13. 13. Full Example<br /> SPWeb web = SPControl.GetContextWeb(Context);<br /> SPList tasks = web.Lists[&quot;Tasks&quot;];<br /> SPListItemCollection items=tasks.Items;<br /> foreach(SPListItem item in items)<br /> {<br /> output.Write(item[&quot;Title&quot;].ToString() + item[&quot;Status&quot;].ToString() + &quot;&lt;br&gt;&quot;);<br /> }<br /><br />
  14. 14. Code Example -- Enumerate sites and lists<br />SPSitemySite = SPContext.Current.Site;<br />SPWebCollectionsubSites = mySite.AllWebs;<br />for (inti=0;i&lt;subSites.Count;i++)<br />{<br />SPListCollection lists = subSites[i].Lists;<br /> for (int j=0;j&lt;lists.Count;j++)<br /> {<br />Response.Write(SPEncode.HtmlEncode(subSites[i].Title) <br /> + &quot; :: &quot; + SPEncode.HtmlEncode(lists[j].Title) + &quot;&lt;BR&gt;&quot;);<br /> }<br />}<br /><br />
  15. 15. SharePoint Web Services<br />SharePoint have web services APIs for accessing content. The web services layer is built on top of the server OM.<br />Web Services are available remotely<br />Allows manipulation of Lists, Webs, Views, List Items, etc.<br />Functionality will be similar to server object model. <br /> Not all OM functionality available<br /><br />
  16. 16. Getting Started With Web Services<br />Create a Windows Application<br />In Visual Studio, choose ‘Add Web Reference’<br />Enter http://&lt;server&gt;/_vti_bin/lists.asmxto access the lists web service<br />Other services include:<br />UserGroups.asmx – users and groups<br />Webs.asmx – Web information<br />Views.asmx – View information<br />Subscription.asmx – Subscriptions<br /><br />
  17. 17. Feature<br /><ul><li>Essentially a chunk of code
  18. 18. Features make it easier to activate or deactivate functionality.
  19. 19. Provide scope for deployment.
  20. 20. All the functionality has been grouped as bunch of features in SharePoint.</li></ul><br />
  21. 21. Feature<br /><ul><li>Demo
  22. 22. Activate Feature
  23. 23. De-Activate Feature
  24. 24. Show the Effects of Activation and De-Activation</li></ul><br />
  25. 25. Solution<br /><ul><li>A solution is a deployable, reusable package that can contain a set of Features, site definitions, and assembliesFeatures make it easier to activate or deactivate functionality.
  26. 26. Solutions can be enabled or disabled.
  27. 27. A solution file has a .CAB-based format but a .WSP extension.</li></ul><br />
  28. 28. Terms with Solutions<br /><ul><li>Manifest.xml
  29. 29. This file defines the list of features such as site definitions, resource files, Web Part files, and assemblies to process.
  30. 30. Only the resources included in this file are processed.
  31. 31. DDF File
  32. 32. Defines the structure of the .cab file
  33. 33. makecab.exe tool to create the solution package.</li></li></ul><li>Solution Overview<br /><br />
  34. 34. Online Training on SharePoint 2007<br />Check Training Details @Training Details<br />Moss Experts<br /><br />