Intro to SharePoint Web Services

5,315

Published on

Published in: Technology
2 Comments
0 Likes
Statistics
Notes
  • Great Tutorial Mr. Rackley i am finding about Microsoft SharePoint Web Services, i hope so this is very help full for me.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Adding below adds value to the presentation slides:

    SharePoint Web Services are WCF Data Services
    LINQ to Entities can be used to access data by generating ORM without relying on complicated CAML.
    Accessing SharePoint list data or update can be done directly using ORM, Web services is an alternative.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total Views
5,315
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide

Intro to SharePoint Web Services

  1. 1. Introduction To SharePoint Web Services Mark Rackley – Solutions Architect Email: mrackley@gmail.com Blog: http://www.sharepointhillbilly.com Twitter: http://www.twitter.com/mrackley
  2. 2. Pescadigitation
  3. 3. Agenda • Introduction to Web Services • Introduction to SharePoint Web Services • Web Services Programming Fundamentals • Dissecting a SharePoint Web Service Call • Demos 3
  4. 4. What We WON’T Cover (but will point out a couple of things) • Security • Scalability • Performance 5 Eric Shupps Microsoft SharePoint MVP “Serve It Up: Building Collaborative Applications with SharePoint Web Services” http://www.sharepointcowboy.com
  5. 5. Section 1 Introduction to Web Services 6
  6. 6. What is a Web Service? 7 According to the World Wide Web Consortium (W3C): "a Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards." [W3C04]
  7. 7. 8
  8. 8. Let’s try it again… 9 A simplistic definition: "a Web service is a software system for sending and receiving data between computer systems over a network following predefined standards.“
  9. 9. Web Services… • Language independent • Operating System independent • Do not use browsers or HTML to communicate – Machine-to-machine communication • Do not have a GUI • Expose an application program interface (API) • Uses HTTP • Typically return results as XML 10
  10. 10. See How Easy It Is? http://www.webservicex.net/stockquote.asmx?WSDL 11
  11. 11. See How Easy It Is? http://www.webservicex.net/stockquote.asmx?WSDL 12
  12. 12. XML Response 13 <StockQuotes> <Stock> <Symbol>MSFT</Symbol> <Last>25.10</Last> <Date>10/19/2010</Date> <Time>4:00pm</Time> <Change>-0.72</Change> <Open>25.27</Open> <High>25.37</High> <Low>24.95</Low> <Volume>66146964</Volume> <MktCap>217.2B</MktCap> <PreviousClose>25.82</PreviousClose> <PercentageChange>-2.79%</PercentageChange> <AnnRange>22.73 - 31.58</AnnRange> <Earns>2.101</Earns> <P-E>12.29</P-E> <Name>Microsoft Corpora</Name> </Stock> </StockQuotes>
  13. 13. Section 2 Introduction to SharePoint Web Services 14
  14. 14. The Basics • Provide remote access to a range of object model functionality • Encapsulate common functions for lists, webs, site collections, and more • Run on all front-end web servers • Heavily dependent on XML and CAML • Reside in physical file system in the 12... Directory and in a virtual file system in /_vti_bin 15
  15. 15. Common Uses 16 Web Service Description Path Alerts Show and delete alerts /_vti_bin/alerts.asmx Authentication Used for forms-based authentication /_vti_bin/authentication.asmx Copy Copies files within and between SharePoint sites /_vti_bin/copy.asmx Document Workspace Web Service Manage Document Workspace and data within /_vti_bin/dws.asmx Forms Shows the forms associated with a list and data about them /_vti_bin/forms.asmx Imaging Work with picture libraries /_vti_bin/imaging.asmx List Data Pull data from within SharePoint lists /_vti_bin/dspsts.asmx Lists Work with lists and list data /_vti_bin/lists.asmx Meetings Create and manage meeting workspaces /_vti_bin/meetings.asmx People Resolve and find users /_vti_bin/people.asmx Permissions Work with list and site permissions /_vti_bin/permissions.asmx Directory Management Manage AD distribution groups and members /_vti_bin/sharepointemailws. asmx Site Data Show metadata or list data from sites and lists /_vti_bin/sitedata.asmx Sites Returns information about site collections or site templates /_vti_bin/sites.asmx Search Allows you to access search results outside of SharePoint /_vti_bin/spsearch.asmx Users and Groups Work with Users and Groups /_vti_bin/usergroup.asmx Versions Work with file versions /_vti_bin/versions.asmx Views Manage list views /_vti_bin/views.asmx Web Part Pages Work with web part pages /_vti_bin/webpartpages.asmx Webs Work with sites and subsites /_vti_bin/webs.asmx http://msdn.microsoft.com/en-us/library/cc752745.aspx
  16. 16. Common Uses 17 Web Service Description Path Area Area interface for remote clients /_vti_bin/areaservice.asmx Official File Sending files and file properties to records repository /_vti_bin/officialfile.asmx Published Links Returns list of published links /_vti_bin/publishedlinksservice.asmx MOSS Search Allows access to the Enterprise Search /_vti_bin/search.asmx User Profile Change Provides remote ability to create or modify user profiles /_vti_bin/userprofilechangeservice.asmx User Profile Service Manage user profiles /_vti_bin/userprofileservice.asmx Workflow Allows starting of workflows and retrieving information about workflows /_vti_bin/workflow.asmx http://msdn.microsoft.com/en-us/library/cc824213.aspx
  17. 17. What They Do • Provide programmatic access via .NET and SharePoint Designer • Deliver relatively robust remote API functionality • Expose SharePoint data repository to disconnected clients • Permit inter-farm communication (geographic distribution) • Integrate well with WinForms, WPF, and SilverLight • Client Object Model (SP 2010) 18
  18. 18. What They Don’t Do • Do not provide access to entire object model • Do not permit manipulation of BLOB objects (documents) • NTLM and Basic Authentication Only • No SSO integration • No extensibility (sealed classes) • Limited data aggregation 19
  19. 19. When to Use Them • Remote accessibility • Integration with backend or legacy systems • Retrieval of items and content as XML • Perform large batch updates to lists • Leverage encapsulated OM functions • Cross-farm programmability • Creation of Data Form Web Parts in SharePoint Designer • Interaction with InfoPath Forms 20
  20. 20. Section 3 Web Services Programming Fundamentals 21
  21. 21. References • Add a Web Reference to any project type • Must specify existing SharePoint site in URL + “/_vti_bin/” + ServiceName + “.asmx” – Uses existing authentication context, beware permission issues • Set URL to dynamic 22
  22. 22. Syntax • XML is your friend – CAML is the red-headed step child • All column names are XML encoded and prefixed with “ows_” – Watch out for spaces, dashes, and other characters in site column/content type/list field names • Long column names will be truncated in the ows_Name field – Use ows_DisplayName to match field names in UI 23
  23. 23. CAML • CAML – Collaborative Application Markup Language – Think of it as XML SQL? – Use tools to help generate CAML (YACAMLQT) • All Query parameters must be provided in CAML syntax • Return values often include CAML constructs – List Schema – View Scheme – Content Types 24
  24. 24. CAML Examples 25 WHERE Email="mrackley@gmail.com" <Where> <Eq> <FieldRef Name="Email" /> <Value Type="Text">mrackley@gmail.com</Value> </Eq> </Where>
  25. 25. CAML Examples 26 WHERE Email<>"mrackley@gmail.com" <Where> <Neq> <FieldRef Name="Email" /> <Value Type="Text">mrackley@gmail.com</Value> </Neq> </Where>
  26. 26. CAML Examples 27 WHERE ID<>null <Where> <IsNotNull> <FieldRef Name="ID" /> </IsNotNull> </Where>
  27. 27. CAML Examples 28 WHERE ID<>null and Email="mrackley@gmail.com" <Where> <And> <IsNotNull> <FieldRef Name="ID" /> </IsNotNull> <Eq> <FieldRef Name="Email" /> <Value Type="Text">mrackley@gmail.com</Value> </Eq> </And> </Where>
  28. 28. CAML Examples 29 WHERE ID<>null or Email="mrackley@gmail.com" <Where> <Or> <IsNotNull> <FieldRef Name="ID" /> </IsNotNull> <Eq> <FieldRef Name="Email" /> <Value Type="Text">mrackley@gmail.com</Value> </Eq> </Or> </Where>
  29. 29. CAML Examples 30 WHERE (Email<>"mrackley@gmail.com" and Email<>"mrackley@unfi.com") OR ID > 10 <Where> <Or> <And> <Neq> <FieldRef Name="Email" /> <Value Type="Text">mrackley@gmail.com</Value> </Neq> <Neq> <FieldRef Name="Email" /> <Value Type="Text">mrackley@unfi.com</Value> </Neq> </And> <Gq> <FieldRef Name="ID" /> <Value Type="Integer">10</Value> </Gq> </Or> </Where>
  30. 30. CAML Operators 31 Operator Meaning Eq = Gt > Lt < Geq >= Leq <= Neq <> Contains Like IsNull Null IsNotNull NotNull BeginsWith Text begins with OrderBy Sort order for a query. GroupBy Contains a Group By section for grouping the data returned through a query in a list view Source: http://www.a2zdotnet.com/View.aspx?id=90
  31. 31. Error Handling • Most web services will throw SoapException or nothing at all • Error information is contained within XML result set – 0x00000000 indicates success – Any other value is error or warning followed by description (hopefully) 32
  32. 32. SharePoint Emoticons • 0;# “12;#Some Value“ • 0x0020 Spaces_0x0020_Are_0x0020_Fun • ows_ All returned fields are prepended • -1001 Possible Boolean values • rs:Data • z:row 33
  33. 33. Large Data Sets • Batch updates via Web Services surpass OM at ~500 items • Large batch updates may exceed thresholds – SOAP exceptions • Extremely large lists (100k+) non- performant over-the-wire • Use LINQ to XML to improve query performance 34
  34. 34. Architecture Concerns • HTTP overhead on WFE’s • Database impact from large read/write operations • Site naming conventions – SPD does not permit spaces in reference name • Performance impact from parsing large XML sets in memory • NTLM/Basic Authentication only
  35. 35. Section 4 Dissecting a SharePoint Web Service Call 36
  36. 36. Example Call to GetListItems 37
  37. 37. GetListItems XML Response 38 <rs:data ItemCount="1" xmlns:rs="urn:schemas-microsoft-com:rowset"> <z:row ows_Title="Elmer@Fudd.com" ows_MetaInfo="4764;#" ows__ModerationStatus="0" ows__Level="1" ows_ID="4764" ows_owshiddenversion="5" ows_UniqueId="4764;#{2272A40C-0DA5-4C0D-938D- BFF3AF9C8ACF}" ows_FSObjType="4764;#0" ows_Created="2009-12-12 12:55:10" ows_FileRef="4764;#sps/Contact/test/Lists/Issues/4764_.000" xmlns:z="#RowsetSchema" /> </rs:data>
  38. 38. Example Call to UpdateListItems 39
  39. 39. SPServices • http://spservices.codeplex.com • jQuery library to call SharePoint Web Services 40
  40. 40. Spservices Example Call
  41. 41. DEMOS! (Real World Scenario Even) 42
  42. 42. Where We Are – Hey! We have SharePoint.. Let’s use it!
  43. 43. First Step – Get New Data in SharePoint
  44. 44. Part B – Get Legacy Data into SharePoint
  45. 45. Step 3 – Enhance with jQuery
  46. 46. Questions? Mark Rackley mrackley@gmail.com www.twitter.com/mrackley www.sharepointhillbilly.com 47

×