Client side programming with SharePoint 2010 - SharePoin Saturday Vietnam


Published on

Presented by PHAM Van Trung, This topic will introduce the solutions to work with SharePoint 2010 from Client side, including:
• SP Client Object Model
• SP Silverlight Client Object Model
- SP ECMAScript Client Object Model
- SP WebServices ; WCF; REST; RPC
- Silverlight + JQuery + SP WebServices (

SharePoint Saturday Vietnam 22/01/11 was sponsored by Officience. Visit

  • Be the first to comment

  • Be the first to like this

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

No notes for slide
  • SharePoint Object Model is the main component when working with SharePoint but it’s only available on the SharePoint ServerApplications using it must run on a SharePoint ServerThe Applications can connect directly to SharePoint Content DB, but this case should never happenedThe SharePoint Content DB is very complexThe DB is maintain by MS, and could be updated on the hotfixs…Clients working with SharePointVia Web Browsers with data rendered via Web ControlsVia Web Services (Standard SP Web Services and Custom Web Services)Not providing all the functions of SharePoint Object Model, need to add more functions on Web Services after an update or create custom Web ServicesWeb Services are not easy to useInput parameters and return result use XML documentsXML data needs to parsed manually – not serialize or deserializeNot very intuitiveRPC: Remote Procedure Call Protocol (owssvr.dll)Using by SharePoint DesignerNot provides all the functions on SharePoint Object ModelCustom Services: FTP, WCF…
  • Throughout each SharePoint release, Microsoft receives more and more requests for new Web ServicesInstead of continuously building new Web services (and replacing existing ASMX services with WCF services), they now provide a client object modelThe client object model provides an abstraction layer so process off the SharePoint server can interact with SharePoint using a consistent API that is very closely matched to the familiar server API
  • Design GoalsConsistencyEfficiency
  • The Client Object Model contains a lot of overlap coverage with the full SharePoint API
  • Similar to programming against server objects in the server context, the new client-side object models use a ClientContext object as the "center of gravity" for all operations. The process of obtaining and working with sites and data begins by retrieving a context object.Show the various resources and their locationsServer – Microsoft.SharePoint – [..]\\14\\ISAPI .NET – Microsoft.SharePoint.Client – [..]\\14\\ISAPISilverlight – Microsoft.SharePoint.Client.Silverlight – [..]\\14\\LAYOUTS\\ClientBinECMAScript– SP.js - [..]\\LAYOUTS
  • Keep efficiency in mindSpecifying the properties to loadQuickly generate CAML using the CreateAllItemsQuery() method
  • By default, the managed client object models authenticate users by using their Windows credentials (DefaultCredentials). Optionally, you can change the authentication mode on the ClientContext object and specify using Forms authentication instead. A user must then supply a user name and password through properties on ClientContext. Behind the scenes, Windows SharePoint Services “14” calls the Authentication Web service, obtains the correct cookie, and then makes the necessary object model calls. To run managed client code against a Forms authentication server, you must change to Forms authentication. This requirement does not apply to the JavaScript object model.The managed client object models provide a ClientAuthenticationMode enumeration whose values are Anonymous, Default, andFormsAuthentication. To specify Forms authentication, use code similar to the following:clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;In addition to setting the authentication mode, you must specify the user name and password information, such as follows:FormsAuthenticationLoginInfoformsAuthInfo = new FormsAuthenticationLoginInfo("MyUser", "MyPassword");clientContext.FormsAuthenticationLoginInfo = formsAuthInfo; Note: Currently, the account name and password in formsAuthInfo are sent in clear text, so you must use HTTPS protocol instead of HTTP.
  • • Callback methods are executed on another thread than the UI thread• Use Invokes to alter the UI from the Use Invokes to alter the UI from the background thread!A Web Part can be a host for SilverlightSharePoint ships with Silverlight web partThe web part can contain custom properties that are sent to Silverlight via the InitParameters propertyThe XAP file can be deployed to LAYOUTS and loaded at run timeThe Silverlight application can then make use of the Client OM.For Silverlight client installations, Microsoft SharePoint Foundation deploys Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll into a special "Scripts only" folder of the /_layouts virtual directory named clientbin. This folder is designed to be a standard place for hosting assemblies that are used in Silverlight.
  • Compressed and crunched .js files for the ECMAScriptobject model, named SP.js, SP.Core.js, and SP.Runtime.js, are installed in the /_layouts directory. Microsoft SharePoint Foundation also includes uncrunched, debug versions of the .js files named SP.debug.js, SP.Core.debug.js, and SP.Runtime.debug.js. You can toggle which .js file is used in Microsoft SharePoint Foundation by setting ScriptMode="Debug" in web.config. If you add <SharePoint:ScriptLinkrunat=”server” Name=”sp.js” Localizable=”false” LoadAfterUI=”true” /> to the page, the Microsoft.SharePoint.WebControls.ScriptLink server control registers all dependencies.You should be aware of the following important differences between the ECMAScriptand managed client object models.The method signature may be different, as with the ClientContext constructorThe two object models use different data value types. The ECMAScriptobject model does not have equivalents for all the data value types in the .NET Framework managed object model. ECMAScriptregards StringCollection as string[]. On the other hand, ECMAScripthas some values that the .NET Framework does not have, such as NaN, or negative and positive infinity.The ECMAScript object model requires that you include security validation on the page through a FormDigest control; for example, <SharePoint:FormDigest id="MyFormDigest" runat="server"/>.
  • Client side scenariosStory in SharePoint 2007 SharePoint 2010 Client Object ModelsOverview of the Client Object Models.NET Client Object ModelSilverlight Client Object ModelECMAScript Client Object ModelADO.NET Data ServicesJQuery, SP WebServices and Silverlight
  • Client side programming with SharePoint 2010 - SharePoin Saturday Vietnam

    1. 1. Client side programming with SharePoint 2010<br />Trung Van PHAM<br />
    2. 2. Client side scenarios<br />Story in SharePoint 2007<br /> SharePoint 2010 Client Object Models<br />Overview of the Client Object Models<br />.NET Client Object Model<br />Silverlight Client Object Model<br />ECMAScript Client Object Model<br />ADO.NET Data Services<br />JQuery, SP WebServices and Silverlight<br />Agenda<br />
    3. 3. Scenarios<br />Web Browsers<br />Microsoft Office Applications<br />Custom Applications<br />Commonly interaction with SharePoint<br />Display SharePoint data<br />Manipulating with SharePoint data<br />Client side scenarios<br />
    4. 4. Story in SharePoint 2007<br />SharePoint Server<br />Applications<br />Web UIs<br />Web Browsers<br />SharePoint<br />Object Model<br />Web Services, RPC<br />Applications<br />Custom Services<br />SharePoint Content DB<br />
    5. 5. Client Object Model provides complete API instead of more services<br />Provides an abstraction layer to return results as recognizable SharePoint objects<br />Consistent developer experience across platforms (.NET, ECMAScript, Silverlight)<br />Overview of the Client Object Models <br />
    6. 6. SharePoint 2010 Client Object Models<br />SharePoint Server<br />Applications<br />Client.svc<br />Client Apps<br />SharePoint<br />Object Model<br />Client OMs<br />SharePoint Content DB<br />
    7. 7. How does Client OM work?<br />SharePoint Server<br />Client Application<br />Build sequence commands:<br /><ul><li>Command 1
    8. 8. Command 2
    9. 9. Command n</li></ul>Execute Commands<br />Client.svc<br />Execute:<br /><ul><li>Command 1
    10. 10. Command 2
    11. 11. Command n</li></ul>Send result back<br />XML<br />Process result<br />JSON<br />
    12. 12. Site Collections and Sites<br />Lists, List Items, Views, and List Schemas<br />Files and Folders<br />Web, List, and List Item Property Bags<br />Web Parts<br />Security<br />Content Types<br />Site Templates and Site Collection Operations<br />Supported Areas<br />
    13. 13. Consistency<br />
    14. 14. C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14ISAPI<br />Files<br />Microsoft.SharePoint.Client.dll (282KB)<br />Microsoft.SharePoint.Client.Runtime.dll (146 KB)<br />Compare to SharePoint Server OM<br />Microsoft.SharePoint.dll (16.2 MB)<br />.NET Client Object Model<br />
    15. 15. DEMO 1<br />Getting Started<br />.NET Client Object Model (cont)<br />
    16. 16. Think about efficiency <br />All the properties are loaded in DEMO1<br />Specify the properties you need:<br />ctx.Load(web, w=>w.Title);<br />ctx.Load(list,l=>l.Title, l=>l.ItemCoun);<br />ctx.ExecuteQuery();<br />.NET Client Object Model (cont)<br />
    17. 17. DEMO 2<br />Specifying properties to load<br />.NET Client Object Model (cont)<br />
    18. 18. Loading List Items <br />List Items are always loaded using a CAML Query<br />[[Code]] - tbd<br />.NET Client Object Model (cont)<br />
    19. 19. DEMO 3<br />Loading List Items<br />.NET Client Object Model (cont)<br />
    20. 20. DEMO 4<br />Creating and Updating List Items<br />.NET Client Object Model (cont)<br />
    21. 21. C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTSClientBin<br />Files:<br />Microsoft.SharePoint.Client.Silverlight.dll (266K)<br />Microsoft.SharePoint.Client.Silverlight.Runtime.dll (142K)<br />Silverlight Client Object Model<br />
    22. 22. [[tbd]] Code<br />Silverlight Client Object Model (cont)<br />
    23. 23. DEMO 5<br />Creating the Silverlight Web Part<br />Silverlight Client Object Model (cont)<br />
    24. 24. C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS<br />Files:<br />SP.js (381 KB)<br />Debug version: SP.debug (561 KB)<br />ECMAScript Object Model<br />
    25. 25. [[tbd]] Code<br />ECMAScript Object Model (cont)<br />
    26. 26. DEMO 6<br />ECMAScript Object Model<br />ECMAScript Object Model (cont)<br />
    27. 27. LINQ to SP not implemented in Silverlight<br />ListData.svc provides RESTful access<br />ADO.NET Data Services<br />ListData.svc<br />Loads ADO.NET Data Services handler assembly<br />
    28. 28. DEMO 7<br />REST demo<br />ADO.NET Data Services (c0nt)<br />
    29. 29. SPServices: JQuery Library for SharePoint Web Services <br />Site Url:<br />SPServices<br />
    30. 30. DEMO 8<br />JQuery, SPServices and Silverlight<br />SPServices (cont)<br />
    31. 31. Q & A ?<br />THANK YOU!<br />Summary<br />