SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
WinRT and the Web: Keeping Windows Store Apps Alive and Connected
The Windows Runtime is the runtime that drives Windows 8 and the new Windows Store apps. The runtime enables developers to build rich client apps that run natively on Window 8 devices. In this session, Jeremy Likness explores the various built-in components and APIs that enable Windows Store apps to connect to SOAP, REST, and OData endpoints and syndicate RSS and Atom feeds. Learn how these tools make it easy to build Windows Store apps that are alive and connected to the internet.
The Windows Runtime is the runtime that drives Windows 8 and the new Windows Store apps. The runtime enables developers to build rich client apps that run natively on Window 8 devices. In this session, Jeremy Likness explores the various built-in components and APIs that enable Windows Store apps to connect to SOAP, REST, and OData endpoints and syndicate RSS and Atom feeds. Learn how these tools make it easy to build Windows Store apps that are alive and connected to the internet.
WinRT and the Web: Keeping Windows Store Apps Alive and Connected
1.
Consulting/Training
WinRT and the Web: Keeping
Windows Store Apps Alive and
Connected
2.
Consulting/Training
consulting
Wintellect helps you build better software,
faster, tackling the tough projects and solving
the software and technology questions that
help you transform your business.
Architecture, Analysis and Design
Full lifecycle software development
Debugging and Performance tuning
Database design and development
training
Wintellect's courses are written and taught by
some of the biggest and most respected names
in the Microsoft programming industry.
Learn from the best. Access the same
training Microsoft’s developers enjoy
Real world knowledge and solutions on
both current and cutting edge
technologies
Flexibility in training options – onsite,
virtual, on demand
Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull
out all the stops to help our customers achieve their goals through advanced software-based
consulting and training solutions.
who we are
About Wintellect
3.
Consulting/Training
Building Windows 8 Apps
http://bit.ly/win8design
“Getting Started Guide”
For the more in depth
“experts guide” wait for
WinRT by Example in
early 2014
4.
Consulting/Training
WinRT and .NET (and a note about Windows 8.1)
WebView
Simple: HTTP (REST)
OData (WCF Data Services)
Syndication
SOAP
WAMS
Agenda
5.
Consulting/Training
Most .NET network classes are
available to WinRT
Some are being moved into WinRT (i.e.
the HttpClient)
Others are proxies and generate pure
.NET code as a function of the IDE
We’ll focus on C# but the WinRT
components are valid for C++ and
JavaScript too
WinRT and .NET
6.
Consulting/Training
Internet Explorer 10 (11 in 8.1) control
In 8.1 it uses a Direct Composition surface
so it can be translated/transformed and
overlaid, in 8.0 – er, ouch, wait for 8.1
Capable of rendering SVG and in 8.1
WebGL
Interoperability with the Windows Store
app (can call to scripts on the page and
vice versa)
Navigation methods (history, journal)
built-in
WebView Control
7.
Consulting/Training
this.WebViewControl.Navigate(new Uri(JeremyBlog));
this.WebViewControl.Navigate(new
Uri("ms-appx-web:///Data/Ellipse.html"));
// can also navigate to streams with a special URI handler in 8.1
this.WebViewControl.NavigateToString(HtmlFragment);
var parameters = new[] { "p/biography.html" };
this.WebViewControl.InvokeScript(
"superSecretBiographyFunction",
parameters);
WebView Control
8.
Consulting/Training
The Embedded Browser: Using WebView
9.
Consulting/Training
.NET for 8.0, WinRT for 8.1
Pure control over HTTP
Viable for REST i.e. serialize/deserialize
directly from JSON and/or XML
Control headers and manage response
as text, stream, etc.
GET, POST, PUT, and DELETE
Using HttpRequestMessage for custom
verbs, etc.
Base class for more specialized clients
HttpClient
10.
Consulting/Training
private static readonly MediaTypeWithQualityHeaderValue Json = new
MediaTypeWithQualityHeaderValue("application/json");
string jsonResponse;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(Json);
jsonResponse = await client.GetStringAsync(productsUri);
}
var json = JsonObject.Parse(jsonResponse);
HttpClient (and a little JSON help)
11.
Consulting/Training
Parsing a REST service with HttpClient and JSON
12.
Consulting/Training
http://msdn.microsoft.com/en-
us/jj658961
Add-on for Visual Studio 2012
Allows right-click and add
reference for service
Generates the proxy and
structures using a data context
(similar to Entity Framework /
WCF RIA)
OData (WCF Services)
14.
Consulting/Training
ServiceBase = new Uri("http://services.odata.org/OData/OData.svc",
UriKind.Absolute);
var client = new ODataService.DemoService(ServiceBase);
var categoryQuery = client.Categories.AddQueryOption("$expand",
"Products");
var categories = await Task<IEnumerable<ODataService.Category>>
.Factory.FromAsync(
categoryQuery.BeginExecute(result => { }, client),
categoryQuery.EndExecute);
OData Client Proxy
15.
Consulting/Training
Connecting to OData using WCF Data Services
16.
Consulting/Training
WinRT (mirrors the .NET equivalent
very closely)
Parses Atom and RSS
Suitable for both consuming and
publishing
Also capable of converting
between formats (i.e. read an Atom
and serve an RSS)
Syndication (Atom/RSS)
17.
Consulting/Training
private static readonly Uri CSharperImageUri = new Uri(
"http://feeds.feedburner.com/CSharperImage/", UriKind.Absolute);
var client = new SyndicationClient();
var feed = await client.RetrieveFeedAsync(CSharperImageUri);
var group = new DataFeed(feed.Id, feed.Title.Text, AuthorSignature,
feed.ImageUri.ToString(), feed.Subtitle.Text);
from item in feed.Items
let content =
Windows.Data.Html.HtmlUtilities.ConvertToText(item.Content.Text)
let summary = string.Format("{0} ...", content.Length > 255 ?
content.Substring(0, 255) : content)
Feed Syndication
19.
Consulting/Training
IDE provides similar interface to OData
Uses WSDL to understand the shape of the service
Considered a more complicated protocol but is
very widely used and has built-in security,
encryption, and other features that are beneficial
to the enterprise
Generates a proxy (client) that is used to handle
the communications (RPC-based)
Can also use channel factories to create clients
SOAP
21.
Consulting/Training
var proxy = new WeatherSoapClient();
var result = await proxy.GetWeatherInformationAsync();
foreach (var item in result.GetWeatherInformationResult)
{
this.weather.Add(item);
}
SOAP Proxy (Generated Client)
22.
Consulting/Training
using (
var factory = new ChannelFactory<WeatherSoapChannel>(
new BasicHttpBinding(), new
EndpointAddress("http://wsf.cdyne.com/WeatherWS/Weather.asmx")))
{
var channel = factory.CreateChannel();
var forecast = await channel.GetCityForecastByZIPAsync(zipCode);
var result = forecast.AsWeatherForecast();
foreach (var day in result.Forecast)
{
day.ForecastUri = await this.GetImageUriForType(day.TypeId);
}
return result;
}
SOAP Proxy (Channel Factory)
23.
Consulting/Training
Connecting to SOAP-based Web Services
24.
Consulting/Training
Affectionately referred to as WAMS
Sample project generated by site; in Windows
8.1 it is literally right-click and “add Windows
Push Notification Service”
Create simple CRUD and other types of services
using hosted SQL
Create push notifications for live updates and
notifications within your app
Windows Azure Mobile Services
25.
Consulting/Training
Windows Azure Mobile Services
26.
Consulting/Training
Windows Azure Mobile Services
27.
Consulting/Training
public static MobileServiceClient MobileService =
new MobileServiceClient(
"https://winrtbyexample.azure-mobile.net/",
"ThisIsASecretAndWillLookDifferentForYou"
);
private IMobileServiceTable<TodoItem> todoTable
= App.MobileService.GetTable<TodoItem>();
var results = await todoTable
.Where(todoItem => todoItem.Complete == false)
.ToListAsync();
items = new ObservableCollection<TodoItem>(results);
ListItems.ItemsSource = items;
Windows Azure Mobile Services
Author Opportunity Passive incomeClear marketing commitments to help grow your personal brand and your coursesInternational presence & exposureCross sell opportunities – instructor led classes, consulting opportunities, and conference speaking opportunitiesOpportunity to be the subject matter expert and to carve out a niche for yourself in this new businessAssociation with Wintellect
0 likes
Be the first to like this
Views
Total views
1,650
On SlideShare
0
From Embeds
0
Number of Embeds
4
You have now unlocked unlimited access to 20M+ documents!
Unlimited Reading
Learn faster and smarter from top experts
Unlimited Downloading
Download to take your learnings offline and on the go
You also get free access to Scribd!
Instant access to millions of ebooks, audiobooks, magazines, podcasts and more.
Read and listen offline with any device.
Free access to premium services like Tuneln, Mubi and more.