3. Agenda
• Introduction to Web Services
• Introduction to SharePoint Web
Services
• Web Services Programming
Fundamentals
• Dissecting a SharePoint Web Service
Call
• Demos
3
4.
5. 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
7. 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]
9. 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.“
10. 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
11. See How Easy It Is?
http://www.webservicex.net/stockquote.asmx?WSDL
11
12. See How Easy It Is?
http://www.webservicex.net/stockquote.asmx?WSDL
12
15. 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
16. 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
17. 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
18. 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
19. 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
20. 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
22. 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
23. 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
24. 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
30. 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>
31. 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
32. 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
33. 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
34. 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
35. 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