Home >Documents >Model Lync Server 2013 REST API Media Manager (Media State) UI Lync Web App Lync for Windows Phone...

Model Lync Server 2013 REST API Media Manager (Media State) UI Lync Web App Lync for Windows Phone...

Date post:29-Dec-2015
Category:
View:231 times
Download:0 times
Share this document with a friend
Transcript:

Build services for any client with ASP.NET Web API

Building services for any client with ASP.NET Web APIDaniel RothSenior Program Manager3-03611/1/2012Windows Azure1 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.How to reach more clients?Browsers

Devices

Phones

Tablets

????AppHow to make it scale?Browsers

Devices

Phones

Tablets

App????Leverage the web build Web APIsBrowsers

Devices

Phones

Tablets

Web APIApp

What is a Web APIAn HTTP serviceDesigned for broad reachUses HTTP as an application protocol, not a transport protocol11/1/2012 4:04 PM2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.5A framework for creating HTTP services that can reach a broad range of clients including browsers and mobile devicesASP.NET Web APIMicrosoft Office 2013Unified communications Web API Powering Lync Web App 2013 and Lync 2013 for Windows Phone 8 Model

Lync Server 2013REST APIMedia Manager(Media State)UILync Web AppLync for Windows PhoneLync for iPhoneLync for iPadLync forAndroidOutlookWeb App JavaScriptC#/XAMLObjective CJavaJavaScriptJavaScriptC++/CC#Language independentModifiableEvent-DrivenMobile-optimized (battery longevity, etc.)Web friendly (JSON & XML)Implements the Lync signaling endpoint business logic

Shields Apps from protocol chattiness.

Keeps up with the full state to deal with client disconnection and aggregates notifications. Client App can sync the information it needs at its own pace.

Abstracts protocol complexity and provides access to all communication & collaboration workloads

APIWEB

ROLEAPPSRTPUIASP.NET WEB APIMODELUCWAUnified Communications Web API (UCWA)

First-class modern HTTP programming modelEasily map resources to URIs and implement the uniform interface of HTTPRich support for formats and HTTP content negotiationEnable hypermedia and link generationSeparate out cross cutting concernsFlexible hostingLight-weight, testable, scalesASP.NET Web APIGetting started with ASP.NET Web APIIncluded with ASP.NET MVC 4 and Visual Studio 2012Available as stand-alone NuGet packagesSupported on .NET 4 and laterDocumentation on http://www.asp.net/web-api Install the ASP.NET Fall 2012 Update preview (http://www.asp.net/vnext) to get the latest featuresYour first Web APIBuild 2012 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.11/1/201211Creating Web APIsDefine your routes (or just use the default one)

Create a new class that derives from APIControllerName your class {controller} + ControllerImplement your actions

routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });Build 2012 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.11/1/201212Web API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersWeb API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersImplementing Web API actionsWeb API actions map to HTTP methodsPrefix your action name with the desired HTTP methodEx GetCustomer, PostComment, DeleteOrder, etc.Use [HttpGet/Post/Put/Delete] if you prefer a different nameOverload actions based on the presence of data in the URI

Note: Action selection can also be done using the {action} route variable just like MVCIEnumerable Get() {}Customer Get(int id) {}Web API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersWeb API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersAction parametersSimple parameter types are taken from the URIRoute data, query parametersComplex parameter types come from the body (only one)Configured MediaTypeFormatters (formatters) are used to deserialize the request body based on the content typeJSON, XML, and formurlencoded supported by defaultOverride using [FromUrl], [FromBody], [ModelBinder], custom parameter bindingYou can always work with HttpRequestMessage directly

Parameter validationValidation is run on the bound parametersSpecify validation rules using DataAnnotations or custom validation logicValidation errors are accumulated in the ModelStateCheck ModelState.IsValidSend back validation errors to client using Request.CreateErrorResponse(ModelState)

Web API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersWeb API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersWeb API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersResponse formatting and content negotiationReturned object is serialized in the response body using configured formattersRequest indicates preferred format using the accept headerServer selects a format for the response based on the request, action return type, configured formattersYou can always just return HttpResponseMessage directlyScaffolding an entity framework code-first based Web APIBuild 2012 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.11/1/201224Web API dispatcherInvoke actionAction filtersParameter bindingSelect actionException filtersRoute to controllerFormattingHttpRequestMessageHttpResponseMessageAuthorization filtersFiltersUsed to handle cross cutting concernsAction filters run before and after invoking an actionAuthorization filters run before model binding and are specifically for authorizing the userException filters handle generating responses for error cases in a centralized wayConfigured globally, per controller, or per action as an attribute (ex [Authorize])

ASP.NET Web API ODataQuerySimply return IQueryable to enable OData query supportAdd an ODataQueryOptions parameter to manage the query yourselfPagingUse [Queryable(ResultLimit=10)] to limit the number of resultsAdd the new ODataMediaTypeFormatter to enable next links using the OData format

OData query and paging ASP.NET Web API ODataFeaturesCRUD operationsQueryAtom and JSON formatsActionsModel builderService Document, $metadataInheritanceCollection properties

Coming post DecSelect, expandContainmentFunctionsChange setsNamed streamsOpen typesEtagsRecursive routingNon-SQL data sources

Support as much query as you want

Lots of custom business logic

When to use ASP.NET Web API ODataWCF Data ServicesASP.NET Web API ODataArchitectureInterfacesComponentsServer? Client?Server and ClientServer onlyMaturityReleasedPreviewOData coverageFullPartial, more comingFlexibilityLowHighKey requirementsIQueryable-Custom business logicMediumEasyFormatsOData onlyAny formatUntypedYesNoHTTP request/respons

Popular Tags:

Click here to load reader

Embed Size (px)
Recommended