Remote Event Receivers

Slides:



Advertisements
Similar presentations
Windows 8 (1) (2) (3) Windows 8 (1) (2) (3)
Advertisements

Feature: Identity Management - Login © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: SmartList Usability Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Windows 8 (1) (2) (3) Windows 8 (1) (2) (3)
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
Feature: Void Historical/Open Transaction Updates © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
Windows Azure SQL Data Sync Name Title Microsoft Corporation.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

Office 365 Development July 2014.
Presenter Date | Location
Microsoft Virtual Academy
Introduction to Windows Azure AppFabric
Microsoft Virtual Academy
6/17/2018 5:54 AM OSP322 Getting the best of both worlds, making the most of SharePoint hybrid search solutions Shyam Narayan Microsoft © 2013 Microsoft.
Business Connectivity Services in SharePoint 2010 and Office 2010
SPC Developer 6/25/2018 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
9/3/ :15 PM Cloud Roadshow © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO.
Microsoft Virtual Academy
SharePoint Online Management and Control
Office 365 Development.
Integrating Microsoft SharePoint 2010 with Windows Azure
Performance Point Services in SP2013
Setting up team development infrastructure for SharePoint 2013
Title of Presentation 11/22/2018 3:34 PM
Microsoft Virtual Academy
Microsoft Virtual Academy
Office Mac /30/2018 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Title of Presentation 12/2/2018 3:48 PM
Microsoft Virtual Academy
Agenda OAuth Concepts Programming OAuth.
Hooking into Apps for SharePoint
Office 365 Development.
Visual Studio 2010 SharePoint Development Tools Overview
2/27/2019 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Create rich, data-driven Web apps with ASP.NET 4.5 Web Forms
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
One Marketing Template
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
Title of Presentation 7/24/2019 8:53 PM
Office 365 Development.
Azure AD Simon May Technical Evangelist.
Microsoft Virtual Academy
Microsoft Virtual Academy
Microsoft Virtual Academy
Microsoft Virtual Academy
Presentation transcript:

Remote Event Receivers Name Title Company

Agenda Introducing Remote Event Receivers Simple Call Scenario Advanced Callback Scenario Developing Remote Event Receivers

Introducing Remote Event Receivers

Remote Event Receivers SharePoint increasingly acting as data hub No way to inform External Systems of events in old version Highly-requested capability by customers Now included in SP2013 External Lists also support events SharePoint is increasingly used as the hub for productivity and collaborative experiences that incorporate and interact with data from a variety of external systems. Capabilities like those offered by Business Connectivity Services offer a powerful infrastructure for surfacing external data inside SharePoint, and SharePoint web services offer an increasing complete set of options for surfacing SharePoint data in outside systems. SharePoint does not, however, currently provide a convenient mechanism for informing external system of SharePoint events. As a result it’s effectively impossible to build an efficient solution that reacts to changes in SharePoint data, except through complex, farm-deployed solutions that use custom event receivers and web service interfaces to call into external systems. Given that farm-deployed solutions are not allowed in SPO, even this solution is not available to Office 365 customers. In addition, the current sandboxed solution infrastructure imposes quite a few restrictions on the developer. For example, solutions can’t execute for longer than 30 seconds, and they cannot exceed a certain amount of resource usage per day. Allowing a developer to execute their event receiver logic outside of the SharePoint farm makes it possible for them to overcome these restrictions and build more robust solutions. This was one of the most highly requested features, providing support for external systems to receive events from SharePoint so they can take action based on that event. There are also enhanced capabilities in Business Connectivity Services to allow external systems to receive information. We aren’t talking about BCS in this module, we’ll talk about that in the BCS module in this course. If you’ve developed event receivers before, you’ll find this very familiar and you’ll be able to leverage your skills with this model.

Remote Event Receivers Microsoft SharePoint Server 2013 Remote Event Receivers Custom Web Service 3. Registered Event Receiver called 4. Line-of-Business System is updated 5. Event Receiver Returns External System 1. User Updates SharePoint List SharePoint Users SharePoint executes events in the following order Synchronous “before” events in sequence order Synchronous “after” events in sequence order Asynchronous “after” events Custom web services implement a required interface and register for events The custom web service can perform any required action and then call back into SharePoint 1. When a user interacts with a supported artifact, then an event fires 2. SharePoint requests ACS to create and sign a token which contains context information about the current user along with an authorization code 3. SharePoint calls the registered event received ( a web service) and passes the context token. The web service validates the signature on the context token and extracts the authorization code 4. The event receiver can do anything it wants. In this case, updating a LOB system 5. The event receiver returns a code to SharePoint indicating the outcome of the event ACS 2. SharePoint requests a token from ACS © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

Remote Event Receivers - Callback Microsoft SharePoint Server 2013 Remote Event Receivers - Callback Custom Web Service 3. Registered Event Receiver called 4. Line-of-Business System is updated 6. Event Receiver calls back into SharePoint 1. User Updates SharePoint List External System 5. Event Receiver Requests a token from ACS SharePoint Users 1. When a user interacts with a supported artifact, then an event fires 2. SharePoint requests ACS to create and sign a token which contains context information about the current user along with an authorization code 3. SharePoint calls the registered event received ( a web service) and passes the context token. The web service validates the signature on the context token and extracts the authorization code 4. The event receiver may perform any action it needs to such as updating a system hosted in the cloud 5. The Remote Event Receiver requests a token from ACS that it can use to call back into SharePoint 6. The Remote Event Receiver can use the token to call back into SharePoint and perform a task ACS 2. SharePoint requests a token from ACS © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

Remote Event Receivers - Architecture Event scopes List Item List Web App Support for the following types Synchronous Events Asynchronous After Events Remote event receivers have event scopes at the list item, list, web, and app level. There is support for both synchronous and asynchronous events. The goal is to make the remote event receivers equivalent to the standard event receivers in SharePoint. If you’ve written event receivers before, you will be able to take advantage of what you know using this new model. In cases where latency is high, remote synchronous events could cause significant delays in the operations that the event is responding to. They are implemented to provide similar support to the standard event receivers, so you’ll need to consider what is appropriate in your scenario. Synchronous events are available today, though, and they’re important, especially for complex data validation rules.

Remote Event Receivers - Architecture RERs not a good choice for “mirroring” or sync solutions Use RER to receive notification that a change has occurred Use interface to poll SharePoint for changes Write changes as required No guaranteed delivery Although custom code can help improve RERs are not good for mirroring or sync solutions. We have seen where people have tried to use event receivers to synchronize data between farms or to update databases when data is changed. These are not good uses of event receivers in either model, but particularly with remote event receivers because there is no guaranteed delivery. You won’t have that message queued up for delivery and then wait for the remote endpoint to come back online to continue processing. The remote endpoint has to be online and listening for the delivery to occur. You can write some custom code to try to improve this, but you don’t receive that out of the box.

Developing Remote Event Receivers

Remote Event Receivers - Development Process Developer builds a custom web service Developer implements required interface in web service Developer registers service with App Web service is called when appropriate SharePoint events occur The high-level design of the remote event receiver is to allow developers to register remote event receivers with SharePoint in a way very similar to the way that local event receivers are registered today. The only major difference is that the developer will provide a web service url rather than an assembly and class name when registering the event receiver. When the event in question occurs, a web service caller will be sent and  the event properties to the specified web service url, and it will expect information about the result of the event receiver in response.  The process involves a developer building a custom web service using the required interface, registering the service, and then the web service is called when the appropriate event occurs.  

Remote Event Receivers - Tooling Add a Remote Event Receiver as a New Item Remote Event receivers can be added directly to App projects.

Remote Event Receivers - Interface Methods Synchronous and asynchronous events are supported ProcessEvent The defined interface supports “ING” events and synchronous “ED” events. ING events occur before the actual event, such as the actual adding of an item to a list or the actual deleting of an item in a list. In this version of SharePoint, we can also specify that the ED events, meaning notification after the event has occurred, we can specify that the call is processed synchronously. ProcessOnewayEvent The defined interface supports asynchronous “ED” The web service takes a single argument of type SPRemoteEventProperties and returns SPRemoteEventResults for synchronous events The web service takes a single argument of type SPRemoteEventProperties and returns void for “ED” events SPRemoteEventProperties will always pass an EventType property, which describes the type of event that is occurring or has occurred. In addition, one of ItemEventProperties, ListEventProperties, or WebEventProperties will be passed, depending on the EventType. For “ING” events, the web service will respond with an object of type SPRemoteEventResult, which will specify the status of the event and, if applicable, the list of changed properties, an error message, and/or a redirect url. The remote event receiver web service caller will only support calling SOAP-based web services The web service caller will use XML serialization The web service caller will depend on the outbound Oauth authentication scheme

Remote Event Receivers Calling Back into SharePoint The boilerplate code that is generated by Visual Studio looks similar to the code above. We use the CreateRemoteEventReceiverClientContext method of the TokenHelper class to obtain a client context based on the context token that is passed to the WCF service. The end result is that you will have a client context that will be used to call back into SharePoint, making advanced scenarios possible where we call back into SharePoint for further processing. The system used to call back into SharePoint, the security tokens and Oauth, are not covered in detail in this module, we have another module that covers that. In this module, we just want to focus on the fact that it’s possible to retrieve the token to be used to make a call back into SharePoint.

Remote Event Receivers - Registration Remote event receivers will be registered through the existing “Receiver” child element of the “Receivers” feature element. It will ignore the “Assembly” and “Class” child elements, and it will add the “Url” child element

Remote Event Receivers - Registration string url= "http://contoso.com/RemoteEventService.svc"; using (SPSite site = new SPSite(siteUrl)) { using (SPWeb web = site.RootWeb) SPList list = web.Lists[listTitle]; list.EventReceivers.Add( SPEventReceiverType.ItemAdded, url); } Object model associated with remote event receivers functions identically to SPEventReceiverDefinition, except that it will have an additional Url property, and the Assembly and Class properties will not be used.

Remote Event Receivers demo

Summary Introducing Remote Event Receivers Simple Call Scenario Advanced Callback Scenario Developing Remote Event Receivers

Q&A

© 2012 Microsoft Corporation. All rights reserved © 2012 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.