SlideShare ist ein Scribd-Unternehmen logo
1 von 25
How the Client Object
Model Saved the Day!
Liam Cleary
Solution Architect | SharePoint MVP
About Me
•   Solution Architect @ SusQtech (Winchester, VA)
•   SharePoint MVP since 2007
•   Working with SharePoint since 2002
•   Worked on all kinds of projects
    •   Internet
    •   Intranet
    •   Extranet
    •   Anything SharePoint Really
• Involved in Architecture, Deployment, Customization and
  Development of SharePoint
It is a wise man who knows
where courage ends and
stupidity begins.
Jerome Cady – Hollywood Screenwriter
Agenda
• Data Access In SharePoint
  • SharePoint 2007
  • SharePoint 2010
• What is the Client Object Model?
  • Managed Code
  • Silverlight
  • ECMAScript
• How can we use it?
• How did it save the day?

• NOTE: Not a heavy code session, well we will see!!
Data Access In SharePoint 2007
• Historically we were tied to direct API or Web Services

       SharePoint Database


          SharePoint API         Server Applications


          Web Services
        (Native / Custom)




        Client Applications
Problems
• Out of the box Web Services may not have the required
  methods
• Custom Web Services can be very complicated to create
• API is not rich enough
  • Custom API wrappers are created
  • Seen this again and again
• Complicated to all from JavaScript / jQuery
• Client Applications if developed are all custom, even data
  access
• Applications are not really developed
• See the same issues with every client
Data Access In SharePoint 2010
• Updated for SharePoint 2010
  • Similar Approach with a few tweaks

               SharePoint Database


                  SharePoint API


     Web Services
                           Client Object Model
   (Native / Custom)




   Client Applications      Server Applications
What is the Client Object Model?
•   “Knight in Shining Armor” for client application development
•   Simple and easy to use API
•   Consistent implementations
•   Abstracted methods from core API
    • Subset of the Types and Members from Microsoft.SharePoint
      namespace
• Three flavors
    • .NET CLR
    • Silverlight
    • ECMAScript (JavaScript, Jscript)
• Easy to Consume data from SharePoint
Client Object Model
   Browser Based
      ECMA Script
      (JavaScript)

  ECMA Script Object
       Model
                                            SharePoint Server
                                              Object Model
          Proxy

                          Client Services
         Client

          Proxy                                SQL Server
                                                Content
                                               Databases
 Managed Object Model


     .NET Managed
   (.NET & Silverlight)
Client Object Model – Process
• Data is retrieved in a specific way

     Client Application                      Server


        Commands                            Client.svc



                             XML
  context.ExecuteQuery();                  Commands



                               JSON
      Process Results                   Send Back Results
Client Object Model - Objects
   • Similar to core API
         • Naming slightly changed
         • Consistent across all implementations

Server                   .NET Managed                    Silverlight                                  JavaScript
(Microsoft.SharePoint)   (Microsoft.SharePoint.Client)   (Microsoft.SharePoint.Cliernt.Silverlight)   (SP.js)

SPContext                ClientContext                   ClientContext                                ClientContext

SPSite                   Site                            Site                                         Site

SPWeb                    Web                             Web                                          Web

SPList                   List                            List                                         List

SPListItem               ListItem                        ListItem                                     ListItem

SPField                  Field                           Field                                        Field
Client Object Model – Getting Started
• No ClientContext = No Connection
clientContext = new ClientContext(“http://mysharepointsite.com”);


• Need to LOAD before you can READ
clientContext.Load(web);
clientContext.Load(web.Lists);

• Must COMMIT requests in a BATCH
clientContext.ExecuteQuery();
clientContext.ExecuteQueryAsync(succeedcallback, failurecallback);
Client Object Model – Object Identities
• Used to batch up objects that can be used before the
  “ExecuteQuery”
ClientContext clientContext = new ClientContext(“http://siteurl”);
List list = clientContext.Web.Lists.GetByTitle(“ListName”);
CamlQuery camlQuery = new camlQuery();
camlQuery.ViewXml = “<View/>”;
ListItemCollection listItems = list.GetItem(camlQuery);
clientContext.Load(list);
clientContext.Load(listItems);
clientContext.ExecuteQuery();

• Once the objects have been set and executed they can be
  iterated through
foreach(ListItem listItem in listItems)
          Console.WriteLine(“Title: ,1-”, listItem*“Title”+,
Client Object Model – Lambda Expressions
• Used trim results, filter or even increase performance
 Trimming
 ClientContext clientContext = new ClientContext("http://siteurl");
 Web site = clientContext.Web;
 clientContext.Load(site,
                s => s.Title,
                s => s.Description);
 clientContext.ExecuteQuery();

 Filter
 ClientContext clientContext = new ClientContext("http://siteurl");
 ListCollection listCollection = clientContext.Web.Lists;
 IEnumerable<List> hiddenLists = clientContext.LoadQuery(
                 listCollection . Where(list => !list.Hidden &&
                 list.BaseType == BaseType.DocumentLibrary)); clientContext.ExecuteQuery();

 Performance
 ClientContext clientContext = new ClientContext("http://siteurl"); IEnumerable<List> lists =
 clientContext.LoadQuery( clientContext.Web.Lists.Include(
                list => list.Title,
                list => list.Hidden,
                list => list.Fields.Include(
                                   field => field.Title,
                                   field => field.Hidden))); clientContext.ExecuteQuery();
Client Object Model – Asynchronous Processing
• Ability to invoke intensive queries Asynchronously
 delegate void AsynchronousDelegate();

 Public void Run()
 {
        ClientContext clientContext = new ClientContext("http://siteurl");
        ListCollection lists = clientContext.Web.Lists;
        IEnumerable<List> newListCollection = clientContext.LoadQuery(
               lists.Include(
                              list => list.Title));

       AsynchronousDelegate executeQueryAsynchronously = new
       AsynchronousDelegate(clientContext.ExecuteQuery);

       executeQueryAsynchronously.BeginInvoke(
             arg =>
             {
                       clientContext.ExecuteQuery();
                       foreach (List list in newListCollection)
                                     Console.WriteLine("Title: {0}", list.Title);
             }, null);
 }
Client Object Model - .NET
• Provides easy access from remote .NET Clients to SharePoint
  Data
• Can be used from Managed Code such as Office
• Utilizes the following Assemblies
  • Microsoft.SharePoint.Client.dll (281 KB)
  • Microsoft.SharePoint.Client.Runtime.dll (145 KB)
• Compared to Microsoft.SharePoint.dll (15.3 MB)
• SQL Like
• Batch Processing
Client Object Model – Managed Code

DEMO
Client Object Model - Silverlight
• Use Silverlight on page or in a web part
• Web Part can contain custom properties by using the “InitParams”
  property
• XAP file deployed to Layouts or Content Database
• Once the Silverlight is loaded it can access the Client Object Model
• Stored in the “14TEMPLATELAYOUTSClientBin” directory
• Utilizes the following Assemblies
  • Microsoft.SharePoint.Client.Silverlight.dll (262 KB)
  • Microsoft.SharePoint.Client.Silverlight.Runtime.dll (138 KB)
• Must call “clientContext.ExecuteQueryAsync”
Client Object Model – Silverlight (WPF)

DEMO
Client Object Model - ECMAScript
• Page needs to load the “SP.js”
  • Use <SharePoint:ScriptLink>
• Can use debug version
   • Use <SharePoint:ScriptLink …ScriptMode=“Debug”>
• Client Context can be set using
 var clientContext = new SP.ClientContext.get_current();
 Or
 var clientContext = new SP.ClientContext();

• SAVE TIME NOTE: Properties are case sensitive
• SP.js (381 KB), SP.Debug.js (561 KB)
Client Object Model – ECMAScript

DEMO
Client Object Model – Wrap-up
• .NET CLR has a Sync Method whereas Silverlight CLR and
  JavaScript are Asynchronous
• All requests are throttled, so be aware of performance
• No ELEVATION of privilege capabilities
  • SPSecurity.RunWithElevatedPrivileges
• Must handle the Synchronize and Update logic
• Need to handle the efficient loading etc. of objects
  • Use LINQ
  • Use Lambda Expressions
• Works well however an element of developer experience is
  needed to use
Client Object Model – How did it save the day?

• Quickly update multiple items on SharePoint
  • No direct Server Access
  • Using Forms Login also
• Add “cool” functionality easily using ECMA Script
  • Inline editing
• Able to track my wife's spending via SharePoint
  • Used Client Object Model to remotely check SharePoint list for
    expenditure and alert on desktop


• Completely made up, but the reality is that simple, this could
  be done, as long as the data feed is available this is achievable
Thank You
•   Personal Email: liamcleary@msn.com
•   Work: http://www.susqtech.com
•   Twitter: @helloitsliam
•   Blog: www.helloitsliam.com

Weitere ähnliche Inhalte

Was ist angesagt?

External collaboration with Azure B2B
External collaboration with Azure B2BExternal collaboration with Azure B2B
External collaboration with Azure B2BSjoukje Zaal
 
SharePoint Saturday Austin - Share point authentication and authorization
SharePoint Saturday Austin - Share point authentication and authorizationSharePoint Saturday Austin - Share point authentication and authorization
SharePoint Saturday Austin - Share point authentication and authorizationLiam Cleary [MVP]
 
What‘s new in Office 365
What‘s new in Office 365What‘s new in Office 365
What‘s new in Office 365SPC Adriatics
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets Redar Ismail
 
WSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure EnterpriseWSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure EnterpriseWSO2
 
Understanding SharePoint Apps, authentication and authorization infrastructur...
Understanding SharePoint Apps, authentication and authorization infrastructur...Understanding SharePoint Apps, authentication and authorization infrastructur...
Understanding SharePoint Apps, authentication and authorization infrastructur...SPC Adriatics
 
SharePoint Saturday The Conference DC - Are you who you say you are share poi...
SharePoint Saturday The Conference DC - Are you who you say you are share poi...SharePoint Saturday The Conference DC - Are you who you say you are share poi...
SharePoint Saturday The Conference DC - Are you who you say you are share poi...Liam Cleary [MVP]
 
Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)SPC Adriatics
 
Demystifying SharePoint Infrastructure – for NON-IT People
 Demystifying SharePoint Infrastructure – for NON-IT People  Demystifying SharePoint Infrastructure – for NON-IT People
Demystifying SharePoint Infrastructure – for NON-IT People SPC Adriatics
 
IBM Watson Work Services Development
IBM Watson Work Services DevelopmentIBM Watson Work Services Development
IBM Watson Work Services DevelopmentVan Staub, MBA
 
Dear Azure: External collaboration with Azure AD B2B
Dear Azure: External collaboration with Azure AD B2BDear Azure: External collaboration with Azure AD B2B
Dear Azure: External collaboration with Azure AD B2BSjoukje Zaal
 
Session 2 Integrating SharePoint 2010 and Windows Azure
Session 2   Integrating SharePoint 2010 and Windows AzureSession 2   Integrating SharePoint 2010 and Windows Azure
Session 2 Integrating SharePoint 2010 and Windows AzureCode Mastery
 
Building Secure Extranets with Claims-Based Authentication #SPEvo13
Building Secure Extranets with Claims-Based Authentication #SPEvo13Building Secure Extranets with Claims-Based Authentication #SPEvo13
Building Secure Extranets with Claims-Based Authentication #SPEvo13Gus Fraser
 
Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthKashif Imran
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoNCCOMMS
 
DEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environment
DEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environmentDEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environment
DEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environmentFelipe Prado
 
Windows Azure Active Directory
Windows Azure Active DirectoryWindows Azure Active Directory
Windows Azure Active DirectoryPavel Revenkov
 
Switching to Oracle Document Cloud
Switching to Oracle Document CloudSwitching to Oracle Document Cloud
Switching to Oracle Document CloudBrian Huff
 

Was ist angesagt? (20)

External collaboration with Azure B2B
External collaboration with Azure B2BExternal collaboration with Azure B2B
External collaboration with Azure B2B
 
SharePoint Saturday Austin - Share point authentication and authorization
SharePoint Saturday Austin - Share point authentication and authorizationSharePoint Saturday Austin - Share point authentication and authorization
SharePoint Saturday Austin - Share point authentication and authorization
 
What‘s new in Office 365
What‘s new in Office 365What‘s new in Office 365
What‘s new in Office 365
 
Portal and Intranets
Portal and Intranets Portal and Intranets
Portal and Intranets
 
WSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure EnterpriseWSO2Con USA 2017: Building a Secure Enterprise
WSO2Con USA 2017: Building a Secure Enterprise
 
Understanding SharePoint Apps, authentication and authorization infrastructur...
Understanding SharePoint Apps, authentication and authorization infrastructur...Understanding SharePoint Apps, authentication and authorization infrastructur...
Understanding SharePoint Apps, authentication and authorization infrastructur...
 
Social Login
Social LoginSocial Login
Social Login
 
SharePoint Saturday The Conference DC - Are you who you say you are share poi...
SharePoint Saturday The Conference DC - Are you who you say you are share poi...SharePoint Saturday The Conference DC - Are you who you say you are share poi...
SharePoint Saturday The Conference DC - Are you who you say you are share poi...
 
Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)Developing social solutions on Microsoft technologies (SP Social and Yammer)
Developing social solutions on Microsoft technologies (SP Social and Yammer)
 
Demystifying SharePoint Infrastructure – for NON-IT People
 Demystifying SharePoint Infrastructure – for NON-IT People  Demystifying SharePoint Infrastructure – for NON-IT People
Demystifying SharePoint Infrastructure – for NON-IT People
 
IBM Watson Work Services Development
IBM Watson Work Services DevelopmentIBM Watson Work Services Development
IBM Watson Work Services Development
 
Dear Azure: External collaboration with Azure AD B2B
Dear Azure: External collaboration with Azure AD B2BDear Azure: External collaboration with Azure AD B2B
Dear Azure: External collaboration with Azure AD B2B
 
Session 2 Integrating SharePoint 2010 and Windows Azure
Session 2   Integrating SharePoint 2010 and Windows AzureSession 2   Integrating SharePoint 2010 and Windows Azure
Session 2 Integrating SharePoint 2010 and Windows Azure
 
Building Secure Extranets with Claims-Based Authentication #SPEvo13
Building Secure Extranets with Claims-Based Authentication #SPEvo13Building Secure Extranets with Claims-Based Authentication #SPEvo13
Building Secure Extranets with Claims-Based Authentication #SPEvo13
 
Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuth
 
What's new 365 - Com Camp
What's new 365 - Com CampWhat's new 365 - Com Camp
What's new 365 - Com Camp
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
 
DEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environment
DEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environmentDEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environment
DEF CON 27 - DIRK JAN MOLLEMA - im in your cloud pwning your azure environment
 
Windows Azure Active Directory
Windows Azure Active DirectoryWindows Azure Active Directory
Windows Azure Active Directory
 
Switching to Oracle Document Cloud
Switching to Oracle Document CloudSwitching to Oracle Document Cloud
Switching to Oracle Document Cloud
 

Ähnlich wie SharePoint Saturday The Conference DC - How the client object model saved the day

Building dynamic applications with the share point client object model
Building dynamic applications with the share point client object modelBuilding dynamic applications with the share point client object model
Building dynamic applications with the share point client object modelEric Shupps
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Ben Robb
 
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio AnguloLuis Du Solier
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Roy de Kleijn
 
Client Object Model - SharePoint Extreme 2012
Client Object Model - SharePoint Extreme 2012Client Object Model - SharePoint Extreme 2012
Client Object Model - SharePoint Extreme 2012daniel plocker
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...SharePoint Saturday NY
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound IntegrationsSujit Kumar
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
Rest API and Client OM for Developer
Rest API and Client OM for DeveloperRest API and Client OM for Developer
Rest API and Client OM for DeveloperInnoTech
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and ReactMike Melusky
 
Integrate MongoDB & SQL data with a single REST API
Integrate MongoDB & SQL data with a single REST APIIntegrate MongoDB & SQL data with a single REST API
Integrate MongoDB & SQL data with a single REST APIEspresso Logic
 
NEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsNEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsAmazon Web Services
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandboxElaine Van Bergen
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0Ido Flatow
 
SharePoint 2013 APIs
SharePoint 2013 APIsSharePoint 2013 APIs
SharePoint 2013 APIsJohn Calvert
 

Ähnlich wie SharePoint Saturday The Conference DC - How the client object model saved the day (20)

Building dynamic applications with the share point client object model
Building dynamic applications with the share point client object modelBuilding dynamic applications with the share point client object model
Building dynamic applications with the share point client object model
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010
 
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Client Object Model - SharePoint Extreme 2012
Client Object Model - SharePoint Extreme 2012Client Object Model - SharePoint Extreme 2012
Client Object Model - SharePoint Extreme 2012
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 
SFDC Inbound Integrations
SFDC Inbound IntegrationsSFDC Inbound Integrations
SFDC Inbound Integrations
 
Ajax workshop
Ajax workshopAjax workshop
Ajax workshop
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
Rest API and Client OM for Developer
Rest API and Client OM for DeveloperRest API and Client OM for Developer
Rest API and Client OM for Developer
 
AWS Lambda in C#
AWS Lambda in C#AWS Lambda in C#
AWS Lambda in C#
 
06 web api
06 web api06 web api
06 web api
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
 
Integrate MongoDB & SQL data with a single REST API
Integrate MongoDB & SQL data with a single REST APIIntegrate MongoDB & SQL data with a single REST API
Integrate MongoDB & SQL data with a single REST API
 
NEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsNEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# Applications
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
SharePoint 2013 APIs
SharePoint 2013 APIsSharePoint 2013 APIs
SharePoint 2013 APIs
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

SharePoint Saturday The Conference DC - How the client object model saved the day

  • 1. How the Client Object Model Saved the Day! Liam Cleary Solution Architect | SharePoint MVP
  • 2. About Me • Solution Architect @ SusQtech (Winchester, VA) • SharePoint MVP since 2007 • Working with SharePoint since 2002 • Worked on all kinds of projects • Internet • Intranet • Extranet • Anything SharePoint Really • Involved in Architecture, Deployment, Customization and Development of SharePoint
  • 3. It is a wise man who knows where courage ends and stupidity begins. Jerome Cady – Hollywood Screenwriter
  • 4.
  • 5. Agenda • Data Access In SharePoint • SharePoint 2007 • SharePoint 2010 • What is the Client Object Model? • Managed Code • Silverlight • ECMAScript • How can we use it? • How did it save the day? • NOTE: Not a heavy code session, well we will see!!
  • 6. Data Access In SharePoint 2007 • Historically we were tied to direct API or Web Services SharePoint Database SharePoint API Server Applications Web Services (Native / Custom) Client Applications
  • 7. Problems • Out of the box Web Services may not have the required methods • Custom Web Services can be very complicated to create • API is not rich enough • Custom API wrappers are created • Seen this again and again • Complicated to all from JavaScript / jQuery • Client Applications if developed are all custom, even data access • Applications are not really developed • See the same issues with every client
  • 8. Data Access In SharePoint 2010 • Updated for SharePoint 2010 • Similar Approach with a few tweaks SharePoint Database SharePoint API Web Services Client Object Model (Native / Custom) Client Applications Server Applications
  • 9. What is the Client Object Model? • “Knight in Shining Armor” for client application development • Simple and easy to use API • Consistent implementations • Abstracted methods from core API • Subset of the Types and Members from Microsoft.SharePoint namespace • Three flavors • .NET CLR • Silverlight • ECMAScript (JavaScript, Jscript) • Easy to Consume data from SharePoint
  • 10. Client Object Model Browser Based ECMA Script (JavaScript) ECMA Script Object Model SharePoint Server Object Model Proxy Client Services Client Proxy SQL Server Content Databases Managed Object Model .NET Managed (.NET & Silverlight)
  • 11. Client Object Model – Process • Data is retrieved in a specific way Client Application Server Commands Client.svc XML context.ExecuteQuery(); Commands JSON Process Results Send Back Results
  • 12. Client Object Model - Objects • Similar to core API • Naming slightly changed • Consistent across all implementations Server .NET Managed Silverlight JavaScript (Microsoft.SharePoint) (Microsoft.SharePoint.Client) (Microsoft.SharePoint.Cliernt.Silverlight) (SP.js) SPContext ClientContext ClientContext ClientContext SPSite Site Site Site SPWeb Web Web Web SPList List List List SPListItem ListItem ListItem ListItem SPField Field Field Field
  • 13. Client Object Model – Getting Started • No ClientContext = No Connection clientContext = new ClientContext(“http://mysharepointsite.com”); • Need to LOAD before you can READ clientContext.Load(web); clientContext.Load(web.Lists); • Must COMMIT requests in a BATCH clientContext.ExecuteQuery(); clientContext.ExecuteQueryAsync(succeedcallback, failurecallback);
  • 14. Client Object Model – Object Identities • Used to batch up objects that can be used before the “ExecuteQuery” ClientContext clientContext = new ClientContext(“http://siteurl”); List list = clientContext.Web.Lists.GetByTitle(“ListName”); CamlQuery camlQuery = new camlQuery(); camlQuery.ViewXml = “<View/>”; ListItemCollection listItems = list.GetItem(camlQuery); clientContext.Load(list); clientContext.Load(listItems); clientContext.ExecuteQuery(); • Once the objects have been set and executed they can be iterated through foreach(ListItem listItem in listItems) Console.WriteLine(“Title: ,1-”, listItem*“Title”+,
  • 15. Client Object Model – Lambda Expressions • Used trim results, filter or even increase performance Trimming ClientContext clientContext = new ClientContext("http://siteurl"); Web site = clientContext.Web; clientContext.Load(site, s => s.Title, s => s.Description); clientContext.ExecuteQuery(); Filter ClientContext clientContext = new ClientContext("http://siteurl"); ListCollection listCollection = clientContext.Web.Lists; IEnumerable<List> hiddenLists = clientContext.LoadQuery( listCollection . Where(list => !list.Hidden && list.BaseType == BaseType.DocumentLibrary)); clientContext.ExecuteQuery(); Performance ClientContext clientContext = new ClientContext("http://siteurl"); IEnumerable<List> lists = clientContext.LoadQuery( clientContext.Web.Lists.Include( list => list.Title, list => list.Hidden, list => list.Fields.Include( field => field.Title, field => field.Hidden))); clientContext.ExecuteQuery();
  • 16. Client Object Model – Asynchronous Processing • Ability to invoke intensive queries Asynchronously delegate void AsynchronousDelegate(); Public void Run() { ClientContext clientContext = new ClientContext("http://siteurl"); ListCollection lists = clientContext.Web.Lists; IEnumerable<List> newListCollection = clientContext.LoadQuery( lists.Include( list => list.Title)); AsynchronousDelegate executeQueryAsynchronously = new AsynchronousDelegate(clientContext.ExecuteQuery); executeQueryAsynchronously.BeginInvoke( arg => { clientContext.ExecuteQuery(); foreach (List list in newListCollection) Console.WriteLine("Title: {0}", list.Title); }, null); }
  • 17. Client Object Model - .NET • Provides easy access from remote .NET Clients to SharePoint Data • Can be used from Managed Code such as Office • Utilizes the following Assemblies • Microsoft.SharePoint.Client.dll (281 KB) • Microsoft.SharePoint.Client.Runtime.dll (145 KB) • Compared to Microsoft.SharePoint.dll (15.3 MB) • SQL Like • Batch Processing
  • 18. Client Object Model – Managed Code DEMO
  • 19. Client Object Model - Silverlight • Use Silverlight on page or in a web part • Web Part can contain custom properties by using the “InitParams” property • XAP file deployed to Layouts or Content Database • Once the Silverlight is loaded it can access the Client Object Model • Stored in the “14TEMPLATELAYOUTSClientBin” directory • Utilizes the following Assemblies • Microsoft.SharePoint.Client.Silverlight.dll (262 KB) • Microsoft.SharePoint.Client.Silverlight.Runtime.dll (138 KB) • Must call “clientContext.ExecuteQueryAsync”
  • 20. Client Object Model – Silverlight (WPF) DEMO
  • 21. Client Object Model - ECMAScript • Page needs to load the “SP.js” • Use <SharePoint:ScriptLink> • Can use debug version • Use <SharePoint:ScriptLink …ScriptMode=“Debug”> • Client Context can be set using var clientContext = new SP.ClientContext.get_current(); Or var clientContext = new SP.ClientContext(); • SAVE TIME NOTE: Properties are case sensitive • SP.js (381 KB), SP.Debug.js (561 KB)
  • 22. Client Object Model – ECMAScript DEMO
  • 23. Client Object Model – Wrap-up • .NET CLR has a Sync Method whereas Silverlight CLR and JavaScript are Asynchronous • All requests are throttled, so be aware of performance • No ELEVATION of privilege capabilities • SPSecurity.RunWithElevatedPrivileges • Must handle the Synchronize and Update logic • Need to handle the efficient loading etc. of objects • Use LINQ • Use Lambda Expressions • Works well however an element of developer experience is needed to use
  • 24. Client Object Model – How did it save the day? • Quickly update multiple items on SharePoint • No direct Server Access • Using Forms Login also • Add “cool” functionality easily using ECMA Script • Inline editing • Able to track my wife's spending via SharePoint • Used Client Object Model to remotely check SharePoint list for expenditure and alert on desktop • Completely made up, but the reality is that simple, this could be done, as long as the data feed is available this is achievable
  • 25. Thank You • Personal Email: liamcleary@msn.com • Work: http://www.susqtech.com • Twitter: @helloitsliam • Blog: www.helloitsliam.com