OData what is OData (Open Data) a protocol for interacting with RESTful web services released under Microsoft's Open Specification Promise works on top of standard HTTP, i.e., uses HTTP get, post, put, and delete verbs returns standard ATOM or JSON (JavaScript Object Notation) formatted results SOAP (formerly Simple Object Access Protocol) vs. REST (Representational State Transfer) SOAP uses XML for data formatting, which can balloon the amount of data sent for large data sets and increase time to parse results REST is able to use JSON to format, keeps quantity of data down, but sometimes still uses ATOM XML format REST puts queries and predicates in the URL, e.g., http://odata.netflix.com/Catalog/Titles and http://odata.netflix.com/Catalog/Titles?$filter=Name%20eq%20'Bad%20News%20Bears' REST relies on standard HTTP SOAP can use pretty much any transport REST is completely stateless, so non-atomic operations are difficult SOAP allows developers to compose complex operations more easily REST allows for easier caching of data sets because of the statelessness 6 principles: Metadata: a machine-readable description of the data model exposed by a particular data provider. slight analogy to WSDL. Data: sets of data entities and the relationships between them. Querying: requesting that the service perform a set of filtering and other transformations to its data, then return the results. Editing: creating, editing, and deleting data. Operations: invoking custom logic Vocabularies: attaching custom semantics and annotations to metadata or data e.g., specifying appropriate data ranges data model Entities: correspond to individual records of entity types, e.g., a Customer or a Product Entity sets: named collections of entities, e.g., a Customers data table Relationships: named navigation definitions between entity sets, i.e., foreign key definitions Complex types: are keyless nominal structural types consisting of a set of properties commonly used as parameters to operations Entity key: Uniquely identifies an entity within a collection, e.g., primary key formed from a subset of primitive properties (e.g. CustomerId, OrderId, LineId, etc.) of the entity type, i.e., compound primary key Declared properties: specified in the entity type’s definition open entity types: entities which permit extra undeclared properties called dynamic properties must not have the same name as a declared property. Operations: allow the execution of custom logic on parts of the model Functions: do not allow side effects and so are composable Actions: allow side effects and so are not composable. both are global to the service and MAY be used as members of entities and collections of entities Structural elements: composed of other model elements e.g., entity types, complex types, association types, and row types are all structural elements. Row types: unnamed structural elements Resource: anything in the model that can be addressed an entity set, entity, property, or operation service model Metadata Document: static definition defining the data model and type system provided by the service Service Document: lists all top-level entity sets available both are machine readable defined in detail in the Common Schema Definition Language spec OData providers: SharePoint itself via WFC services, Azure, Azure Marketplace, SSRS show list of public feeds BCS overview make it easy to integrate external data using an External Content Type (ECT) acts like an ORM e.g., Django for Python or ActiveRecord for Rails, or NHibernate in .NET ECTs: map fields in external data sources to entities in the local environment, provide a standard schema for interacting with data define operations that can be performed on external data, i.e., CRUD operations in 2010, ECTs already supported SOAP web services and WCF services, but OData support is new in 2013 VS 2012 project item: Content Types for an External Data Source contains a designer to show fields and specify filters and limits connectors: support interaction with a specific type of data source OOTB: SQL databases, web services, now OData can create .NET assembly connectors and custom connectors .NET assembly connectors used for relatively static schemas that won't change i.e., external systems that are still in-house custom connector better for external systems out of developer's control implemented as a service application in SharePoint i.e., go to Central Admin -> Application Management -> Manage services on server or Manage service applications metadata store: holds all ECTs created to interact with external systems secure store services: credential mapping system for external systems that don't necessarily use AD and standard Windows Security e.g., Twitter: probably has an AD system for the enterprise side but regular users just have a username and password instead of an AD account or maybe an OAuth token BCS Stereotypes: Finder SpecificFinder Creator Updater Deleter AssociationNavigator External Lists act like a regular SharePoint list with internal data populated with items from the external data feed Office client-side apps include a data caching mechanism in addition to metadata caching to allow users to work with data in a disconnected setting SharePoint sites cache only the metadata and perform queries to retrieve data SP 2013 improvements: in 2010, large data sets caused issues with sorting and filtering because the entire data set was retrieved, with sorting and filtering performed locally in 2013, data sets can be sorted and filtered remotely because "predicates" controlling sorting and filtering are sent to the service with the request before data is retrieved OData and SQL support both sorting and filtering, WCF services do not support sorting Automatic generation of BDC models for OData data sources ECT model: XML file, in 2010, developers needed to handle themselves in 2013, Visual Studio handles the generation of the BDC model Support for SharePoint 2013 apps can package BDC models within apps so they don't affect the rest of the system can still use system-wide BDC connections, access granted by administrators Export to Excel setting up BCS service go to Central Admin -> Application Management -> Manage service applications create BDC service app go to Central Admin -> Application Management -> Manage services on server ensure service app is started Start the Business Connectivity Services service app remote event receivers new in SP 2013 additions to BDC schema: EventSubscriber and EventUnsubscriber able to catch events on external data sources, e.g., new item, edited item works if remote system supports notifications, e.g., MS Project 2013 new functionality added: alerts: users can receive regular SharePoint alerts based on changes or additions in external OData feeds event receivers: developers can write code that gets executed on the local system when data is modified example: Using an OData feed from Dynamics CRM, you could write an event receiver that fires when a new lead is added to the system. The event receiver can collect information about the new lead and create tasks or start a workflow to remind salespeople to contact the new lead and follow through on the sales process. Demo browse to OData ecosystem page - local IE browse to a couple of OData feeds, e.g., Netflix or eBay - local IE browse to Northwind feed Customers JSON - local IE Northwind feed service document - cloudshare IE Northwind feed metadata document - cloudshare IE OData1 project - local VM create external content type source: http://services.odata.org/Northwind/Northwind.svc/ note checkbox to auto-create lists view a couple of ECTs show created lists create a new view usage of data in code - cloudshare VS CSOM showItems JS functions: note how data is accessed e.g., data.d.results, val.CustomerID, val.ContactName