SlideShare a Scribd company logo
try 
{ 
// Creamos el HttpClient 
HttpClient httpClient = new HttpClient(); 
// Opcionalmente definimos los Headers 
httpClient.DefaultRequestHeaders.Accept.TryParseAdd("application/json"); 
// Y hacemos la llamada 
string responseText = await httpClient.GetStringAsync( 
new Uri("http://services.odata.org/Northwind/Northwind.svc/Suppliers")); 
} 
catch (Exception ex) 
{ 
... 
}
try 
{ 
var client = new HttpClient(); 
var uri = new Uri(" http://example.com/customers/1"); 
var response = await client.GetAsync(uri); 
// código de status y la respuesta del servicio 
var statusCode = response.StatusCode; 
// EnsureSuccessStatusCode tira una excepción cuando no es HTTP 200 
response.EnsureSuccessStatusCode(); 
var responseText = await response.Content.ReadAsStringAsync(); 
} 
catch (Exception ex) 
{ 
... 
Content 
Headers 
StatusCode 
ReasonPhrase 
IsSuccessStatusCode 
Source 
Version 
RequestMessage 
} 
HttpClient 
A diferencia del ejemplo anterior, usa GetAsync en lugar de GetStringAsync si necesitas el código de 
respuesta, headers, etc.
try 
{ 
var client = new HttpClient(); 
var uri = new Uri("http://example.com/customers/1"); 
var response = await client.GetAsync(uri); 
// display headers 
foreach (var header in response.Headers) 
{ 
HeadersText.Text += header.Key + " = " + header.Value + "n" ; 
} 
ResultsText.Text = await response.Content.ReadAsStringAsync(); 
} 
catch (Exception ex) 
{ ...}
var client = new HttpClient(); 
// se agregan los headers 
var headers = client.DefaultRequestHeaders; 
headers.Referer = new Uri("http://contoso.com"); 
var ok = headers.UserAgent.TryParseAdd("testprogram/1.0"); 
// se hace la petición 
var response = await client.GetAsync(uri); 
// se obtiene la longitude de la respuesta 
var length = response.Content.Headers.ContentLength.Value; 
byte[] buffer = new byte[length]; 
Headers 
Es recomendable usar el método TryParseAdd para recibir un booleano en 
lugar de una excepción en caso de algún fallo. 
Header Access 
Accept read/write collection 
AcceptEncoding read/write collection 
AcceptLanguage read/write collection 
Authorization read/write 
CacheControl read/write collection 
Connection read/write collection 
Cookie read/write collection 
Date read/write 
Expect read/write collection 
From read/write 
Host read/write 
IfModifiedSince read/write 
IfUnmodifiedSince read/write 
MaxForwards read/write 
ProxyAuthorization read/write 
Referer read/write 
TransferEncoding read/write collection 
UserAgent read/write collection
try 
{ 
var client = new HttpClient(); 
// estamos mandando un delete request 
var request = new HttpRequestMessage(HttpMethod.Delete, uri); 
// no esperamos una respuesta, pero lo usamos de todas formas 
var response = await client.SendRequestAsync(request); 
// mostramos el status code del request 
HeadersText.Text = "Status: " + response.StatusCode + "n"; 
} 
catch (Exception ex) 
{ … } 
Delete 
Get 
Head 
Options 
Patch 
Post 
Put 
Also, new 
HttpMethod(string) for 
your own methods 
SendRequestAsync 
HttpClient incluye los métodos para Put y Post, pero también se puede utilizar el método 
SendRequestAsync para hacer cualquier tipo de request, incluyendo Delete
http://manage.windowsazure.com
16
17
18 
private async System.Threading.Tasks.Task InsertToDoItem() 
{ 
IMobileServiceTable<TodoItem> TodoTable = App.TaskMasterDemoClient.GetTable<TodoItem>(); 
TodoItem t = new TodoItem(); 
t.Title = titleTextBox.Text; 
t.Description = descriptionTextBox.Text; 
t.DueDate = dueDatePicker.Date.ToString(); 
t.AssignedTo = assignedToTextBox.Text; 
try 
{ 
await TodoTable.InsertAsync(t); 
} 
catch (Exception) 
{ /* TODO: Insert error handling code */ } 
}
19
20
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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.

More Related Content

What's hot

Connecting to the network
Connecting to the networkConnecting to the network
Connecting to the networkMu Chun Wang
 
UAA for Kubernetes
UAA for KubernetesUAA for Kubernetes
UAA for Kubernetes
Altoros
 
Troubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud FoundryTroubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud Foundry
Altoros
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum
 
Laporan tugas network programming
Laporan tugas network programmingLaporan tugas network programming
Laporan tugas network programming
RahmatHamdani2
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Javaelliando dias
 
Retrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberRetrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saber
Bruno Vieira
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
belajarkomputer
 
Textile
TextileTextile
Hiding secrets in Vault
Hiding secrets in VaultHiding secrets in Vault
Hiding secrets in Vault
Neven Rakonić
 
Ravada VDI Eslibre
Ravada VDI EslibreRavada VDI Eslibre
Ravada VDI Eslibre
frankiejol
 
Reactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OReactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/O
Arawn Park
 
NestJS
NestJSNestJS
NestJS
Wilson Su
 
Retro vs volley (2)
Retro vs volley (2)Retro vs volley (2)
Retro vs volley (2)
Artjoker Digital
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
Daniel Costa Gimenes
 
Code as Risk
Code as RiskCode as Risk
Code as Risk
Kevlin Henney
 
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofitjSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession
 

What's hot (20)

Connecting to the network
Connecting to the networkConnecting to the network
Connecting to the network
 
UAA for Kubernetes
UAA for KubernetesUAA for Kubernetes
UAA for Kubernetes
 
Troubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud FoundryTroubleshooting .NET Applications on Cloud Foundry
Troubleshooting .NET Applications on Cloud Foundry
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
 
Laporan tugas network programming
Laporan tugas network programmingLaporan tugas network programming
Laporan tugas network programming
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
Retrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberRetrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saber
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
Textile
TextileTextile
Textile
 
Winform
WinformWinform
Winform
 
Node intro
Node introNode intro
Node intro
 
Hiding secrets in Vault
Hiding secrets in VaultHiding secrets in Vault
Hiding secrets in Vault
 
Ravada VDI Eslibre
Ravada VDI EslibreRavada VDI Eslibre
Ravada VDI Eslibre
 
Reactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/OReactive Web - Servlet & Async, Non-blocking I/O
Reactive Web - Servlet & Async, Non-blocking I/O
 
NestJS
NestJSNestJS
NestJS
 
Retro vs volley (2)
Retro vs volley (2)Retro vs volley (2)
Retro vs volley (2)
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Code as Risk
Code as RiskCode as Risk
Code as Risk
 
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofitjSession #4 - Maciej Puchalski - Zaawansowany retrofit
jSession #4 - Maciej Puchalski - Zaawansowany retrofit
 

Viewers also liked

Mapa mental dato, información, sistema y programa
Mapa mental dato, información, sistema y programaMapa mental dato, información, sistema y programa
Mapa mental dato, información, sistema y programa
jenny allendes
 
trabajo de estadistica
 trabajo de estadistica trabajo de estadistica
trabajo de estadistica
luce0218
 
TRABAJO DE MINDOMO
TRABAJO DE MINDOMOTRABAJO DE MINDOMO
TRABAJO DE MINDOMO
sergio simbaA
 
Propuesta de Innovación Educativa
Propuesta de Innovación EducativaPropuesta de Innovación Educativa
Propuesta de Innovación Educativa
Martha Santa Ana
 
Ppt nielsen piensa en ti 2
Ppt nielsen piensa en ti 2Ppt nielsen piensa en ti 2
Ppt nielsen piensa en ti 2
Reinaldo Díaz
 
Taller algoritmo
Taller algoritmoTaller algoritmo
Taller algoritmo
Lele Barragan
 
Plantilla de presentación del proyecto de aula
Plantilla de presentación del proyecto de aulaPlantilla de presentación del proyecto de aula
Plantilla de presentación del proyecto de aula
Dianasimonl
 
Proceso de comprensión lectora
Proceso de comprensión lectoraProceso de comprensión lectora
Proceso de comprensión lectora
Josefina Delia
 
Act 1 individual
Act 1 individualAct 1 individual
Act 1 individualHlsanchez
 
Grupo Riego Centinno
Grupo Riego CentinnoGrupo Riego Centinno
Grupo Riego Centinno
rolferwinmuller
 
Uso académico de cuentas creadas para el PLE
Uso académico de cuentas creadas para el PLEUso académico de cuentas creadas para el PLE
Uso académico de cuentas creadas para el PLE
Leydy Porras Alvarez
 
37459207 importancia-de-los-metodos-numericos
37459207 importancia-de-los-metodos-numericos37459207 importancia-de-los-metodos-numericos
37459207 importancia-de-los-metodos-numericos
Novato de la Weeb Fox Weeb
 
Presentacion crowdsourcing solucion problematica
Presentacion crowdsourcing solucion problematicaPresentacion crowdsourcing solucion problematica
Presentacion crowdsourcing solucion problematica
lcreyes
 
Sanciones a proveedores y arbitros
Sanciones a proveedores y arbitrosSanciones a proveedores y arbitros
Sanciones a proveedores y arbitros
Ivanov Torres
 
Tipos de energía
Tipos de energíaTipos de energía
Tipos de energía
jhasveidy2000
 
Flujograma
FlujogramaFlujograma
Flujograma
jenny allendes
 
Personas a seguir
Personas a seguirPersonas a seguir
Personas a seguir
Guillermo Luc
 

Viewers also liked (20)

Mapa mental dato, información, sistema y programa
Mapa mental dato, información, sistema y programaMapa mental dato, información, sistema y programa
Mapa mental dato, información, sistema y programa
 
memoria RAM
memoria RAMmemoria RAM
memoria RAM
 
trabajo de estadistica
 trabajo de estadistica trabajo de estadistica
trabajo de estadistica
 
TRABAJO DE MINDOMO
TRABAJO DE MINDOMOTRABAJO DE MINDOMO
TRABAJO DE MINDOMO
 
Propuesta de Innovación Educativa
Propuesta de Innovación EducativaPropuesta de Innovación Educativa
Propuesta de Innovación Educativa
 
Ppt nielsen piensa en ti 2
Ppt nielsen piensa en ti 2Ppt nielsen piensa en ti 2
Ppt nielsen piensa en ti 2
 
Noticia 6 de abril 2014.pdf
Noticia 6 de abril 2014.pdfNoticia 6 de abril 2014.pdf
Noticia 6 de abril 2014.pdf
 
Taller algoritmo
Taller algoritmoTaller algoritmo
Taller algoritmo
 
Plantilla de presentación del proyecto de aula
Plantilla de presentación del proyecto de aulaPlantilla de presentación del proyecto de aula
Plantilla de presentación del proyecto de aula
 
Proceso de comprensión lectora
Proceso de comprensión lectoraProceso de comprensión lectora
Proceso de comprensión lectora
 
Act 1 individual
Act 1 individualAct 1 individual
Act 1 individual
 
Grupo Riego Centinno
Grupo Riego CentinnoGrupo Riego Centinno
Grupo Riego Centinno
 
Uso académico de cuentas creadas para el PLE
Uso académico de cuentas creadas para el PLEUso académico de cuentas creadas para el PLE
Uso académico de cuentas creadas para el PLE
 
Diptico
DipticoDiptico
Diptico
 
37459207 importancia-de-los-metodos-numericos
37459207 importancia-de-los-metodos-numericos37459207 importancia-de-los-metodos-numericos
37459207 importancia-de-los-metodos-numericos
 
Presentacion crowdsourcing solucion problematica
Presentacion crowdsourcing solucion problematicaPresentacion crowdsourcing solucion problematica
Presentacion crowdsourcing solucion problematica
 
Sanciones a proveedores y arbitros
Sanciones a proveedores y arbitrosSanciones a proveedores y arbitros
Sanciones a proveedores y arbitros
 
Tipos de energía
Tipos de energíaTipos de energía
Tipos de energía
 
Flujograma
FlujogramaFlujograma
Flujograma
 
Personas a seguir
Personas a seguirPersonas a seguir
Personas a seguir
 

Similar to Conociendo el consumo de datos en Windows Phone 8.1

13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authentication
WindowsPhoneRocks
 
Asynchronous in dot net4
Asynchronous in dot net4Asynchronous in dot net4
Asynchronous in dot net4Wei Sun
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
Yakov Fain
 
Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#
Rainer Stropek
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)danwrong
 
AJAX
AJAXAJAX
AJAX
AJAXAJAX
jQuery - Chapter 5 - Ajax
jQuery - Chapter 5 -  AjaxjQuery - Chapter 5 -  Ajax
jQuery - Chapter 5 - Ajax
WebStackAcademy
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxWildan Maulana
 
The Promised Land (in Angular)
The Promised Land (in Angular)The Promised Land (in Angular)
The Promised Land (in Angular)
Domenic Denicola
 
#3 (Multi Threads With TCP)
#3 (Multi Threads With TCP)#3 (Multi Threads With TCP)
#3 (Multi Threads With TCP)
Ghadeer AlHasan
 
Fault tolerance made easy
Fault tolerance made easyFault tolerance made easy
Fault tolerance made easy
Uwe Friedrichsen
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best Practices
Jitendra Zaa
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqelajobandesther
 
Android webservices
Android webservicesAndroid webservices
Android webservicesKrazy Koder
 
Core Java tutorial at Unit Nexus
Core Java tutorial at Unit NexusCore Java tutorial at Unit Nexus
Core Java tutorial at Unit Nexus
Unit Nexus Pvt. Ltd.
 
Ajax
AjaxAjax
Ajax
Svirid
 
Unfiltered Unveiled
Unfiltered UnveiledUnfiltered Unveiled
Unfiltered Unveiled
Wilfred Springer
 

Similar to Conociendo el consumo de datos en Windows Phone 8.1 (20)

13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authentication
 
Asynchronous in dot net4
Asynchronous in dot net4Asynchronous in dot net4
Asynchronous in dot net4
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
 
Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#
 
Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)Building @Anywhere (for TXJS)
Building @Anywhere (for TXJS)
 
AJAX
AJAXAJAX
AJAX
 
AJAX
AJAXAJAX
AJAX
 
java sockets
 java sockets java sockets
java sockets
 
jQuery - Chapter 5 - Ajax
jQuery - Chapter 5 -  AjaxjQuery - Chapter 5 -  Ajax
jQuery - Chapter 5 - Ajax
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
 
The Promised Land (in Angular)
The Promised Land (in Angular)The Promised Land (in Angular)
The Promised Land (in Angular)
 
#3 (Multi Threads With TCP)
#3 (Multi Threads With TCP)#3 (Multi Threads With TCP)
#3 (Multi Threads With TCP)
 
Fault tolerance made easy
Fault tolerance made easyFault tolerance made easy
Fault tolerance made easy
 
Apex Testing and Best Practices
Apex Testing and Best PracticesApex Testing and Best Practices
Apex Testing and Best Practices
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
 
Async pattern
Async patternAsync pattern
Async pattern
 
Android webservices
Android webservicesAndroid webservices
Android webservices
 
Core Java tutorial at Unit Nexus
Core Java tutorial at Unit NexusCore Java tutorial at Unit Nexus
Core Java tutorial at Unit Nexus
 
Ajax
AjaxAjax
Ajax
 
Unfiltered Unveiled
Unfiltered UnveiledUnfiltered Unveiled
Unfiltered Unveiled
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Conociendo el consumo de datos en Windows Phone 8.1

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. try { // Creamos el HttpClient HttpClient httpClient = new HttpClient(); // Opcionalmente definimos los Headers httpClient.DefaultRequestHeaders.Accept.TryParseAdd("application/json"); // Y hacemos la llamada string responseText = await httpClient.GetStringAsync( new Uri("http://services.odata.org/Northwind/Northwind.svc/Suppliers")); } catch (Exception ex) { ... }
  • 8.
  • 9. try { var client = new HttpClient(); var uri = new Uri(" http://example.com/customers/1"); var response = await client.GetAsync(uri); // código de status y la respuesta del servicio var statusCode = response.StatusCode; // EnsureSuccessStatusCode tira una excepción cuando no es HTTP 200 response.EnsureSuccessStatusCode(); var responseText = await response.Content.ReadAsStringAsync(); } catch (Exception ex) { ... Content Headers StatusCode ReasonPhrase IsSuccessStatusCode Source Version RequestMessage } HttpClient A diferencia del ejemplo anterior, usa GetAsync en lugar de GetStringAsync si necesitas el código de respuesta, headers, etc.
  • 10. try { var client = new HttpClient(); var uri = new Uri("http://example.com/customers/1"); var response = await client.GetAsync(uri); // display headers foreach (var header in response.Headers) { HeadersText.Text += header.Key + " = " + header.Value + "n" ; } ResultsText.Text = await response.Content.ReadAsStringAsync(); } catch (Exception ex) { ...}
  • 11. var client = new HttpClient(); // se agregan los headers var headers = client.DefaultRequestHeaders; headers.Referer = new Uri("http://contoso.com"); var ok = headers.UserAgent.TryParseAdd("testprogram/1.0"); // se hace la petición var response = await client.GetAsync(uri); // se obtiene la longitude de la respuesta var length = response.Content.Headers.ContentLength.Value; byte[] buffer = new byte[length]; Headers Es recomendable usar el método TryParseAdd para recibir un booleano en lugar de una excepción en caso de algún fallo. Header Access Accept read/write collection AcceptEncoding read/write collection AcceptLanguage read/write collection Authorization read/write CacheControl read/write collection Connection read/write collection Cookie read/write collection Date read/write Expect read/write collection From read/write Host read/write IfModifiedSince read/write IfUnmodifiedSince read/write MaxForwards read/write ProxyAuthorization read/write Referer read/write TransferEncoding read/write collection UserAgent read/write collection
  • 12. try { var client = new HttpClient(); // estamos mandando un delete request var request = new HttpRequestMessage(HttpMethod.Delete, uri); // no esperamos una respuesta, pero lo usamos de todas formas var response = await client.SendRequestAsync(request); // mostramos el status code del request HeadersText.Text = "Status: " + response.StatusCode + "n"; } catch (Exception ex) { … } Delete Get Head Options Patch Post Put Also, new HttpMethod(string) for your own methods SendRequestAsync HttpClient incluye los métodos para Put y Post, pero también se puede utilizar el método SendRequestAsync para hacer cualquier tipo de request, incluyendo Delete
  • 13.
  • 14.
  • 16. 16
  • 17. 17
  • 18. 18 private async System.Threading.Tasks.Task InsertToDoItem() { IMobileServiceTable<TodoItem> TodoTable = App.TaskMasterDemoClient.GetTable<TodoItem>(); TodoItem t = new TodoItem(); t.Title = titleTextBox.Text; t.Description = descriptionTextBox.Text; t.DueDate = dueDatePicker.Date.ToString(); t.AssignedTo = assignedToTextBox.Text; try { await TodoTable.InsertAsync(t); } catch (Exception) { /* TODO: Insert error handling code */ } }
  • 19. 19
  • 20. 20
  • 21. ©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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.

Editor's Notes

  1. Hola, en este módulo conoceremos más sobre el consumo de datos en Windows Phone 8.1 y algunos cambios que se han realizados en esta versión del sistema operativo.
  2. Conoceremos lo que todos deben de saber acerca del consumo de datos en Windows Phone 8.1. Además conoceremos cómo usar HttpClient, para hacer llamadas a directas a servicios web externos. Y además a cómo se pueden crear servicios de backend con Azure Mobile Services además de lo fácil que es crear uno desde Visual Studio
  3. Así que, vamos por lo básico en el consumo de datos
  4. Esto es algo de verdad muy simple, pero los dispositivos móviles no están siempre conectados a Internet (si, no siempre tienen una conexión de internet buena). Y hay veces que la gente lo olvida. Esto es algo que se debe de considerar en las aplicaciones, que no siempre se contará con red WiFi o red celular y esto trabaja diferente que en una PC.   Otra cosa a considerar son los costos de descargas para los usuarios que usan una aplicación. Y avisar a los usuarios o darles la opción de solo sincronizar o descargar datos pesados con una conexión WiFi, y estar seguro que en caso de que no, no se descarguen demasiados datos a la aplicación.   Otra forma es que muestres información precargada, así cuando ingrese a la aplicación no vea un mensaje de "Espera mientras cargamos el contenido". Esto dará una mala experiencia de usuario.
  5. Para que se pueda utilizar, es necesario activar un capability en Windows Phone .1 desde el Package.appxmanifest de la aplicación, exactamente el de Internet (Client & Server)
  6. HTTPClient es una API bastante fácil de usar y muy flexible y tan complicado como tú quieras. Así que esta es la forma en la que se usa cuando no tienes un servicio backend propio. Es más usado en servicios REST, y cuando necesitas algo tan preciso y exacto. Esta es la forma sencilla de usar HttpClient, donde únicamente estaríamos obteniendo un string que podría ser un json, xml o lo que sea. En el código de ejemplo, sólo creamos un HttpClient, después definimos los headers, que en este caso sería el Header de Accept y al final llamamos al servicio con el método GetStringAsync donde le pasamos una Uri.
  7. Hay que resolver al tipo correcto cuando vayamos a usar HttpClient, ya que por default usa System.Net.Http.HttpClient y hay dos. No hay nada malo en usar entre uno y otro, de hecho System.Net lo descargas desde Nuget para Windows Phone 7/8, donde se usan las API de Windows Runtime.   Así que es recomendable que se resuelva la directiva usando Windows.Net.Http para no tener problemas. En un GetStringAsync no podría presentar problemas, pero en opciones más avanzadas es muy probable que si
  8. Así que si quieres algo más complicado, mandas a pedir el request, en lugar de recibir un string, obtienes un mensaje HTTP y te permite revisar los headers, los codigos de status, obtener el stream del contenido, etc. Esto es para obtener más detalles de la petición
  9. También puedes leer los headers de la respuesta del servicio, esto viene en un arreglo dentro del objeto de respuesta en responde.Headers
  10. Así que también cuando mandes información, puedes agregar headers en el request.
  11. Al enviar un request de tipo POST, GET, etc, se realiza de la siguiente manera. Se crea el HttpClient y creamos un objeto de tipo HttpRequestMessage con la información requerida que es el método HTTP, del listado de la derecha y la Uri. Mandamos a llamar al método SendRequestAsync del HttpClient y luego obtenemos la respuesta del servidor. La consulta de servicios en una aplicación no es tan complicado como muchos nos los hacen ver, es bastante sencillo.
  12. Después de conocer cómo se utiliza HttpClient para hacer llamadas a servicios de una forma muy precisa, conoceremos sobre cómo se crea un servicio de backend usando Microsoft Azure y su servicio de Mobile Services. Sólo veremos un pequeño repaso de qué es y cómo se utiliza en una aplicación de Windows Phone.
  13. ¿Qué son los Mobile Services? Te permiten crear un servicio de backend en la nube. Esto funciona para multiples plataformas, soporta iOS, Android, aplicaciones de Windows Store y HTML5, así como Windows Phone. Tu servicio lo puedes escribir en C# o NodeJS. Además puedes crear notificaciones Push, Acceso Empresarial usando Active Directory, Integración con redes sociales como Facebook, Twitter y Google. Y tu base de datos puede ser SQL, Oragle, SAP o MongoDB. Se puede ocupar por muchos dispositivos y tiene todo el potencial que Microsoft Azure ofrece.
  14. En la versión de Visual Studio 2013, ahora te permite crear y modificar tus servicios sin estar en el portal de Microsoft Azure., esto te ayuda a ahorrar tiempo. Aunque también los puedes crear desde el portal de Microsoft Azure.
  15. Así que puedes desde tu proyecto sólo hacer un clic con el botón derecho y seleccionar la opción de Add > Conected Service. Después de eso, puedes administrar tus suscripciones de Microsoft Azure con el que se conectará tu aplicación y desde ahí, se podrá crear un Mobile Service. Una vez que se haya creado el Mobile Service, agregará las referencias necesarias para utilizarse y en el App.xaml.cs agregará código para la configuración de la instancia de los servicios automáticamente.
  16. Además de todo lo anterior, podemos administrar nuestra base de datos desde el Server Explorer y editar desde ahí mismo en Visual Studio, los scripts del servidor e incluso crear más tablas. Así podrás tener un mejor control de todo lo que realizas en Microsoft Azure.
  17. Aspi que tambien es muy sencillo trabajar con tu Mobile Service. Al crear tu servicio y tablas, todo quedará mapeado como objetos, donde como vemos en el método para inserter un Item, se crea un Nuevo objeto de tipo TodoItem y después lo puedes inserter en tu table.
  18. También puedes crear notificaciones push desde Visual Studio, sin abrir el portal de Microsoft Azure como se hacía anteriormente
  19. Pero no todo se limita a lo que acabamos de ver. Puedes agregar usuarios a tus tablas y que estos, puedan autenticarse usando su Microsoft Account o desde Twitter, Facebook o Active Directory. Los scripts del servidor se pueden personalizar para implementar lógica de negocio propia y hasta llamar a servicios de terceros. Incluso puedes crear tareas en segundo plano. En el siguiente módulo crearemos una aplicación de Windows Phone, que utilizará una API del Gobierno del DF en México usando HttpClient, además de un pequeño ejemplo de cómo crear tu propio servicio de backend con los Mobile Services de Microsoft Azure.