SharePoint Alerts with WCF and jQuery
-
Upload
nick-hadlee -
Category
Technology
-
view
4.873 -
download
1
description
Transcript of SharePoint Alerts with WCF and jQuery
Alerts! Creating alerts using the SP 2010 UI Improvements, custom WCF services and jQuery
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
Introduction (Brief) There a couple of things I “prepared earlier” … a brief explanation
WCF Building a custom WCF service for SharePoint 2010 The focus will not be what the service does but how to wire it up
jQuery Instead of using the ASP.NET Ajax / Script Manager lets talk to the WCF service with jQuery
SharePoint 2010 UI Utilities – Status Bar, Modal Dialog and Notifications The UI glue to show the information to users
Session Breakdown
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
The Alert architecture A SharePoint List – the alert storage
A custom WCF Service – the basic business objects / logic and communication mechanism
jQuery – asynchronous data retrieval (on the client)
SP.UI.Status – the presentation layer
Introduction
WCF
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
Can build SOAP, REST or Data Services
Supports dynamic configuration using factories. SharePoint 2010 provides 3 factories:
WCF
Service Type Service Factory Description
SOAP service MultipleBaseAddressBasicHttpBindingServiceHostFactory
Basic HTTP binding must be used, which creates endpoints for a service based on the basic HTTP binding.
REST Service MultipleBaseAddressWebServiceHostFactory
The service factory creates endpoints with Web bindings.
ADO.NET Data Service MultipleBaseAddressDataServiceHostFactory
A data service host factory can be used.
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
Can’t be deployed by a sandbox solution
WCF isn’t 100% supported in SharePoint project templates Create a separate WCF Service Library and copy the files into the SharePoint
project Add references to System.ServiceModel and System.Runtime.Serialization The service declaration (.svc) needs to be added to list of files processed for
replaceable tokens http://msdn.microsoft.com/en-us/library/ee231545.aspx
Create Alert class that represents our alerts for serialization/data
transfer Alert { Title, Description, Link, Colour }
Custom WCF Service in SharePoint 2010
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
Make the service ASP.NET compatible using System.ServiceModel.Activation [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
Make the service REST capable using System.ServiceModel.Web [WebGet(UriTemplate = "/Alert", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
Using MultipleBaseAddressWebServiceHostFactory because its a REST service (sort of)
Custom WCF Service in SharePoint 2010
DEMO: Custom WCF Build
jQuery
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
We could use ASP.NET AJAX but … we won’t
We will use jQuery to call our WCF web service jQuery has built in support for ajax and JSON
jQuery.ajax() jQuery.getJSON()
jQuery
User Interface Utilities – SP.UI
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
SP.UI.Notify addNotification(), Notify(), removeNotification()
SP.UI.Status addStatus(), appendStatus(), removeAllStatus(), removeStatus(),
setStatusPriColor(), Status(), updateStatus()
SP.UI.ModalDialog.showModalDialog(options) options is a JavaScript literal of the properties to pass this method
e.g. var options = { url: “http://sharepoint.com” }
The OOTB UI Improvements in 2010
DEMO: How to use jQuery and SP.UI
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
WCF Services in SharePoint Foundation 2010 http://msdn.microsoft.com/en-us/library/ff521586.aspx
Creating a Custom WCF Service in SharePoint Foundation http://msdn.microsoft.com/en-us/library/ff521581.aspx
jQuery ajax and JSON http://api.jquery.com/jQuery.ajax/ http://api.jquery.com/jQuery.getJSON/
Resources
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
SP.UI.Notify http://msdn.microsoft.com/en-us/library/ff408137.aspx
SP.UI.Status http://msdn.microsoft.com/en-us/library/ff412058.aspx
SP.UI.ModalDialog http://msdn.microsoft.com/en-us/library/ff408909.aspx http://msdn.microsoft.com/en-us/library/ff411351.aspx
Enabling Intellisense in Visual Studio http://msdn.microsoft.com/en-us/library/ff798328.aspx
Resources
SharePoint Saturday New Zealand – WCF, jQuery and the SP Status Bar
SharePoint Consultant at Intergen Blog: nickhadlee.wordpress.com Twitter: @nickhadlee
Nick Hadlee
Questions
Thank you to our Sponsors
MS COMMUNITIES