1 / 14

Consuming SharePoint data using WCF Data Services

Consuming SharePoint data using WCF Data Services. Paul Schaeflein. Steve Smith, MVP, MCSE, MTV, certified loony Company name Company web site E-mail address Short bio optional, such as books/articles written, hobbies, details that will enhance your standing with the audience.

nash-smith
Download Presentation

Consuming SharePoint data using WCF Data Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Consuming SharePoint data using WCF Data Services Paul Schaeflein

  2. Steve Smith, MVP, MCSE, MTV, certified loony • Company name • Company web site • E-mail address • Short bio optional, such as books/articles written, hobbies, details that will enhance your standing with the audience

  3. SharePoint API • https://[site]/_api • Used by both CSOM and REST • Returns single objects (Web, List) and collections (ListItems)

  4. Service Metadata • In OData, this is known as the CSDL(Common Schema Definition Language) • Accessed via a GET request to <serviceRoot>/$metadata • SharePoint 2013 did not support until April 2013 CU

  5. WCF Data Services • ...enables the creation and consumption of OData services for the web (formerly known as ADO.NET Data Services). • Patterns & Practices has SP2010 write-up on REST. WCF portion still relevant • Available as NuGet package • Be sure to get “client” package

  6. Using WCF Data Services • Add Service Reference • Create proxy classes for context and data • ListData context • List items • ApiData context • Everything else

  7. Using WCF Data Services • Data Classes • SharePoint objects as documented in CSOM <EntityContainerName="ApiData"> <EntitySetName="Lists"EntityType="SP.List" /> <EntitySetName="Sites"EntityType="SP.Site" /> <EntitySetName="Webs"EntityType="SP.Web" /> <EntitySetName="Groups"EntityType="SP.Group" /> <EntitySetName="ListItems"EntityType="SP.ListItem" /> <FunctionImportName="contextinfo"IsComposable="true"ReturnType="SP.ContextWebInformation"/> <FunctionImportName="lists"IsComposable="true"EntitySet="Lists"ReturnType="Collection(SP.List)"/> <FunctionImportName="site"IsComposable="true"EntitySet="Sites"ReturnType="SP.Site"/> <FunctionImportName="web"IsComposable="true"EntitySet="Webs"ReturnType="SP.Web"/>

  8. Using WCF Data Services • Data Classes • List data modeled after content type <EntityContainerName="ListData"> <EntitySetName="UserInfoItems"EntityType="SP.Data.UserInfoItem" /> <EntitySetName="ContosoProductsListItems"EntityType="SP.Data.ContosoProductsListItem" /> <EntitySetName="TaxonomyHiddenListListItems"EntityType="SP.Data.TaxonomyHiddenListListItem" /> <EntitySetName="DocumentsItems"EntityType="SP.Data.DocumentsItem" /> <EntitySetName="PublishingImagesItems"EntityType="SP.Data.PublishingImagesItem" /> <EntitySetName="PagesItems"EntityType="SP.Data.PagesItem" /> <EntitySetName="SiteCollectionDocumentsItems"EntityType="SP.Data.SiteCollectionDocumentsItem"/>

  9. Reading SharePoint data using WCF Contoso Products MVC

  10. DataService Context operations • REST methods invoke via Execute method on the context objecthttp://<sitecollection>/<site>/_api/web/lists/getById(id)

  11. DataService Context operations • FunctionImport element <FunctionImportName="GetById"ReturnType="SP.List"IsComposable="true"IsBindable="true"EntitySet="Lists"> <ParameterName="this"Type="Collection(SP.List)" /> <ParameterName="id"Type="Edm.Guid"Nullable="false" /> </FunctionImport> http://<...>/_api/Web/Lists(guid'deef02d2-444b-...1cbb2777')

  12. Updating data • Requires POST tunneling • Sending PUT or MERGE in a POST operation • HTTP Header X-HTTP-Method: PUT • Modify pipeline to send only changed data • Need to include the digest

  13. References • http://www.schaeflein.net/blog/presentations • HTML version of this talk • WCF Data Services • Using the REST Interface (p&p)

  14. Thank you for attending!

More Related