310 likes | 535 Views
OSP-302. Advanced SharePoint Data Access with Microsoft Silverlight . Paul Stubbs Sr. Architect Evangelist Microsoft Corporation. Scot Hillier SharePoint MVP Scot Hillier Technical Solutions, LLC. Agenda. oData Access to SharePoint Lists SharePoint Client Object Model
E N D
OSP-302 Advanced SharePoint Data Access with Microsoft Silverlight Paul Stubbs Sr. Architect Evangelist Microsoft Corporation Scot Hillier SharePoint MVP Scot Hillier Technical Solutions, LLC
Agenda • oData Access to SharePoint Lists • SharePoint Client Object Model • Embedding Data in HTML • SharePoint Web Services and RSS Feeds
oData Access to SharePoint List Data • Open Data Protocol (oData) is a RESTful protocol • Use standard HTTP methods to access data • Implemented in SharePoint through ListData.svc • Utilize WCF Data Services with Silverlight • Install WCF Data Services on SharePoint server • Set Service reference to ListData.svc • Write type safe code against proxy
Keys to Using this Pattern • Service Reference to ListData.svc • Creates proxy • DataServiceCollection • Observable collection for managing changes to data set returned from WCF Data Services • Create from IEnumerable data set • Bind to grid • DataServiceQuery • An abstract class that represents a single query request to WCF Data Services • AddQueryOption method allows additional parameters
oData and Silverlight Scot Hillier SharePoint MVP Scot Hillier Technical Solutions, LLC demo
Silverlight Client Object Model • Silverlight Development Enabled by Client OM • CRUD operations on lists • Change security permissions • Create sites, pages, custom actions • ClientContext • Site • Web • List • ListItem
Keys to Using this Pattern • Using the .NET Client OM requires adding two references • Microsoft.SharePoint.Client.Silverlight.dll • Microsoft.SharePoint.Client.Silverlight.Runtime.dll • Both are found in [..]\14\TEMPLATES\LAYOUTS\ClientBin • Microsoft.SharePoint.Client.Silverlight.dll • Includes the .NET Client OM API’s • Microsoft.SharePoint.Client.Silverlight.Runtime.dll • Handles all the communication, serialization & deserialization between the client application & SharePoint server
Keys to Using this Pattern • Dynamic Loading of the Client Object Model • Microsoft.SharePoint.Client.xap contains assemblies • Download XAP • Remove assemblies • Load them dynamically assemblyStream = Application.GetResourceStream( new StreamResourceInfo(e.Result, "application/binary"), new Uri(“Microsoft.SharePoint.Client.Silverlight.Runtime.dll", UriKind.Relative)).Stream; assemblyPart = new AssemblyPart(); assemblyPart.Load(assemblyStream);
Client Object Model and Silverlight Paul Stubbs Sr. Architect Evangelist Microsoft Corporation demo
Embedding Data in HTML • Hidden Field used to Contain Data • Allows Silverlight Application to read data from the web page instead of returning to server
Keys to Using this Pattern • Create a custom class • Decorate with [DataContract] • Decorate members with [DataMember] • DataContractJsonSerializer DataContractJsonSerializerjs = new DataContractJsonSerializer(this.GetType()); String result = String.Empty; using (MemoryStreamms = new MemoryStream()) { js.WriteObject(ms, this); Result = Encoding.UTF8.GetString(ms.ToArray(), 0, ConvertToInt16(ms.Length)); }
Keys to Using this Pattern • HtmlInputHidden • Represents a hidden control on the page to contain serialized data set • Pass Hidden Control ID to Silverlight • Silverlight Application reads serialized data set • De-serialize data set
Embedding Data in HTML Scot Hillier SharePoint MVP Scot Hillier Technical Solutions, LLC demo
SharePoint Web Services and RSS Feeds • ASMX web services • Get functionality not supported by other methods • Search • Profiles • RSS Feeds for retrieving data
Keys to Using this Pattern • Setting References to ASMX services • As normal in many cases • GUID or CHAR fields can cause errors • AsmxMessageInspector cleans ASMX messages • AsmxBehavior wraps AsmxMessageInspector BasicHttpBinding b = new BasicHttpBinding(); EndpointAddress e = new EndpointAddress(this.profileEndpointAddress); UserProfileServiceSoapClient c= new UserProfileServiceSoapClient(b,e); c.Endpoint.Behaviors.Add(new AsmxBehavior());
Keys to Using this Pattern • RSS Feeds • WebClient class to call RSS feed • SyndicationFeed class to parse XML WebClientwc = new WebClient(); Wc.OpenReadCompleted += new OpenReadCompletedEventHandler(requestComplete); Wc.OpenReadAsync(new Uri(feedUrl));
Keys to Using this Pattern • Cross-domain calls • Clientaccesspolicy.xml (Silverlight) • Crossdomain.xml (Flash) • Must be in root and have no security • Add to SharePoint using an Http Handler • Required because SharePoint enforces authentication • Requires web.config edits • Intercepts calls going into SharePoint • Response.Write policy file into stream
Web Services and RSS Feeds Scot Hillier SharePoint MVP Scot Hillier Technical Solutions, LLC demo
Summary • oData Access to SharePoint Lists • SharePoint Client Object Model • Embedding Data in HTML • SharePoint Web Services and RSS Feeds
Resources • Session Samples on Code Gallery • http://code.msdn.microsoft.com/spsl • Paul’s Blog • http://blogs.msdn.com/pstubbs • Scot’s Blog • http://www.shillier.com
Required Slide Speakers, please list the Breakout Sessions, Interactive Discussions, Labs, Demo Stations and Certification Exam that relate to your session. Also indicate when they can find you staffing in the TLC. Related Content from my team • OSP209| Building Your First Windows Phone 7 Application for Microsoft SharePoint 2010 • OSP301| Integrating Microsoft SharePoint 2010 with Windows Azure • COS375-INT| Integrating Windows Phone 7 and Microsoft SharePoint Using Windows Azure • OSP301| Integrating Microsoft SharePoint 2010 with Windows Azure • OSP319| Taking Office to the Cloud: Integrating Microsoft Office 2010 and Windows Azure • OSP312| Developing Microsoft Office Business Solutions That Span the PC, Windows Phone 7 and Web • OSP304| SAP Interoperability with Duet Enterprise for Microsoft SharePoint and SAP, BCS, and Microsoft Office 2010 • OSP305| Developing Collaboration Solutions in the Cloud with Microsoft SharePoint Online • OSP306| Developing Powerful Workflows in the Cloud with Microsoft SharePoint Online
http://channel9.msdn.com/shows/sharepointsideshow Twitter @SPSideshow
Coming Soon… • Still a work in progress • Get early access and send feedbackon Safari Rough Cuts!http://bit.ly/SPSL_SafariRoughCuts • Download the code on MSDN Code Galleryhttp://code.msdn.com/spsl/
Professional SharePoint 2010 Branding and User Interface Design • CSS • master pages • page layouts • SharePoint themes • XSLT • jQuery • Silverlight • Provides expert tips, techniques, and insights from the author team of SharePoint 2010 branding experts
Resources • Connect. Share. Discuss. http://northamerica.msteched.com Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.