Gill Cleeren Microsoft Regional Director Microsoft MVP ASP.NET Ordina Belgium -

Slides:



Advertisements
Similar presentations
Svetlin Nakov Director Training and Consulting Activities National Academy for Software Development (NASD) ASP.NET 3.5 New Features.
Advertisements

XML Web Services in Visual Studio ®.NET NameTitleCompany.
Introduction to Web Services
Windows Communication Foundation and Web Services.
2 No Silverlight (2) Application is an Island (of richness) Mike Taulty Microsoft UK
What’s in.NET 3.5 for Services? The New HTTP Programming Model New Support for JSON Services Syndication in.NET 3.5.
.NET Framework V3.5+ & RESTful web services Mike Taulty Developer & Platform Group Microsoft Ltd
Ronnie Saurenmann Principal Architect Microsoft Switzerland
Ronnie Saurenmann Principal Architect Microsoft Switzerland.
Microsoft Silverlight Applications Need Data... and Here's How to Get It! Gill Cleeren Microsoft Regional Director Benelux / MVP ASP.NET.NET Software.
What’s new in ASP.NET 3.5? Mike Ormond Developer & Platform Group Microsoft Ltd
Interaction & Transactional Services Interaction & Transactional Services Silverlight Client HTML + XAP Web Browser Site Of Origin Web Server Web.
Switching on the cloud for Silverlight MSDN Live Meeting Gill Cleeren Microsoft Regional Director – Silverlight MVP Ordina Belgium.
Jon Flanders INT303. About Me  Jon Flanders –  Independent consultant/trainer  BizTalk MVP.
RSS RSS is a method that uses XML to distribute web content on one web site, to many other web sites. RSS allows fast browsing for news and updates.
1 Web Services Visual C# 2008 Step by Step Chapter 30.
Getting Started with Windows Communication Foundation 4.5 Ed Jones, MCT, MCPD, MCTS Consultant RBA Inc.
Getting Started with WCF Windows Communication Foundation 4.0 Development Chapter 1.
Introduction SOAP History Technical Architecture SOAP in Industry Summary References.
XML Web Services in Visual Studio.NET Peter Ty Developer Evangelist.NET and Developer Group.
A Scalable Application Architecture for composing News Portals on the Internet Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta Famagusta.
JavaScript & jQuery the missing manual Chapter 11
AJAX Without the “J” George Lawniczak. What is Ajax?
Silverlight 2 has rich networking support SOAP/XML Web services via WCF proxies Untyped HTTP services (REST, RSS, ATOM) via HttpWebRequest and WebClient.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Module 14: WCF Send Adapters. Overview Lesson 1: Introduction to WCF Send Adapters Lesson 2: Consuming a Web Service Lesson 3: Consuming Services from.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Copyright © Orbeon, Inc. All rights reserved. Erik Bruchez Applications of XML Pipelines XML Prague, June 16 th, 2007.
Spicing Up Web Parts Randy Williams SharePoint Hawaii User Group May 11, 2011.
Web Mashups -Nirav Shah.
CSCI 6962: Server-side Design and Programming Web Services.
Tom Castiglia Hershey Technologies
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Ronnie Saurenmann Principal Architect Microsoft Switzerland blogs.msdn.com/swiss_dpe_team.
Intro to WCF From the beginning and uses Steve AppRochester.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Project “Astoria” first announced in Mix 2007 Shared early prototypes, got tons of feedback Now we’re talking about the real deal Production quality bits,
Cross Site Integration “mashups” cross site scripting.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Mahesh Krishnan, Senior Consultant, Readify Slide 1.
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
Telerik Software Academy Web Services & Cloud.
Why data services? Common challenges when creating rich web applications Creating rich web applications with data services Future scenarios & roadmap.
Preliminary Ocean Project Page 1 WGISS SG May 15, C. Caspar G. Tandurella P. Goncalves G. Fallourd I. Petiteville Preliminary Ocean Project Phase.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
1 Alternative view on Internet Computing Web 1.0 –Web 1.0 is first generation, Web Information based. Driven by Information provider. Web 2.0 Ajax enabled.
Windows Communication Foundation David Anderson Independent Software Developer DCOM Productions.
ICM – API Server & Forms Gary Ratcliffe.
Dhananjay Kumar MVP-Connected System 1. WCF  Agenda What is WCF ? Why WCF? Address, Binding, Contract End Points Hosting Message Patterns Programming.
Exploring Mobile Device Networking Lesson 4. Exam Objective Matrix Skills/ConceptsMTA Exam Objectives Understanding Networking for Mobile Devices Network.
OE-NIK HP Advanced Programming WCF WCF SOAP service, host, client Exception handling (NOT required)
OE-NIK HP Advanced Programming Web services Standards and protocols Using web services Using web services with asynchronous calls.
L. (Van) Van Lowe Twitter:lvanlowe
Introduction to Web Services Srinath Vasireddy Support Professional Developer Support Microsoft Corporation.
2 ADO.NET Data Services for the Web Mike Flasko Program Manager, Microsoft “Project Astoria”
ArcGIS for Server Security: Advanced
Windows Communication Foundation and Web Services
Introducing the Microsoft® .NET Framework
Web Mashups -Nirav Shah.
WEB SERVICES.
Unit – 5 JAVA Web Services
Asynchronous Java script And XML Technology
Windows Communication Foundation and Web Services
Maxim Lukiyanov Program Manager Microsoft Corporation
Introduction to World Wide Web
Accessing Web Services in Silverlight 4
Introduction to Web Services and SOA
WCF Data Services and Silverlight
.NET Framework V3.5+ & RESTful web services
Presentation transcript:

Gill Cleeren Microsoft Regional Director Microsoft MVP ASP.NET Ordina Belgium Working with Data and Web Services in Silverlight 2

Get to know the audience… Is this Silverlight?

Agenda Introduction Building our first Silverlight/WCF application Services that describe themselves Services that don’t describe themselves Accessing RSS/Atom feeds Summary

Applications interact with the outside world Product catalog Search string Product database Product information

In-Browser Application Public Internet mashup APIs Existing Intranet services New services you build RSS/Atom Feeds Images Sounds Videos Many Types of Outside Data

A Bit of History: Silverlight 1.0 Public Internet mashup APIs Existing Intranet services New services you build RSS/Atom Feeds Images Sounds Videos JavaScript HTML ? AJAX (XmlHttpRequest) 1.0

2 Managed Code (C#/VB) The Story Today: Silverlight 2 Public Internet mashup APIs Existing Intranet services New services you build RSS/Atom Feeds Images Sounds Videos HTML

Question 1: What does the client code look like? 8 Managed Code (C#/VB) 2

New services you build Question 2: What is the recommended way to create services for Silverlight?

Using a Custom Service from Silverlight 10 Service Product database DEMO

Recap: Required Steps WCF Service 1. Create the Service 2. Define what it does 3. “Add Service Reference” 4. Use the Service!

Creating a Service for Silverlight “Add New Item” (in Web Site / Web App)  “Silverlight-Enabled WCF Service” Temporary for Beta1: “Add New Item”  “WCF Service” Change wsHttpBinding  basicHttpBinding in config basicHttpBinding

Defining the Contract [ServiceContract] for the service class (interface in Beta1) [OperationContract] for methods (in the interface in Beta1) [DataContract]/[DataMember] for data types [ServiceContract] public class ShoppingService { [OperationContract] Product[] GetProducts(string searchString) { /*... Implementation... */ } } [DataContract] public class Product { [DataMember] public string description; [DataMember] public string pictureUrl; } Nothing Silverlight-specific Regular WCF code!

Adding a Reference In the Silverlight project: “Add Service Reference” “Discover” button will find services in solution Can also give external URL

Creating the Proxy var proxy = new ShoppingServiceClient(); Default address chosen if no parameters given Can pass in address manually But what if the service moves? Configuration support after Beta1 No need to recompile Silverlight client code if service moves Can reuse one Silverlight app for many services

Making the Call Only asynchronous calls supported Set up GetProductsCompleted event “Tab,Tab” in Visual Studio Call GetProductsAsync var proxy = new ShoppingServiceClient(); proxy.GetProductsCompleted += new EventHandler (proxy_GetProduc tsCompleted); proxy.GetProductsAsync(“book”); void proxy_GetProductsCompleted(object sender, GetProductsCompletedEventArgs e) { // Process response… } var proxy = new ShoppingServiceClient(); proxy.GetProductsCompleted += new EventHandler (proxy_GetProduc tsCompleted); proxy.GetProductsAsync(“book”); void proxy_GetProductsCompleted(object sender, GetProductsCompletedEventArgs e) { // Process response… }

Data Binding to Services All generated types/collections support data binding Future Possibility: Advanced data binding to services (XAML-only) E.g.

What we covered so far… 2 Public Internet mashup APIs Existing Intranet services New services you build RSS/Atom Feeds Images Sounds Videos

Approach #1: "Add Service Reference" Metadata-driven, with Intellisense 19

Services that describe themselves SOAP services in the enterprise Services for your Silverlight project SQL Server Data Services* (Astoria) SOAP services on the Internet Computer-Readable Metadata (e.g. WSDL) Automatic Proxy Generation WCF

Demo: Demo: Accessing the Live Search API from Silverlight in an automatic way 21

Add Service Reference Works with: Any “simple” SOAP service (e.g. Live Search) SOAP 1.1 Server-side may be JAVA, WCF, ASMX, etc. A few restrictions (e.g. SOAP Faults not supported) Future Possibility: SQL Server Data Services (Astoria) Can’t talk to just any service: Silverlight-Wide Cross-Domain Restrictions…

Cross-Domain Restrictions Silverlight does not allow applications to cross domain boundaries by default: MySite.com/silverlightApplication.xap cannot call SomeOtherSite.com/someService.svc SecurityException if you try Silverlight allows the calls if target site opts in How do services opt in? When should services opt-in?

Cross-Domain Policy Files Silverlight looks for two policy files: Silverlight policy: clientaccesspolicy.xml Adobe Flash policy: crossdomain.xml Already used by All public services that work with Flash will also work with Silverlight!

25 Cross-Domain Policy Files

Approach #2: Write the Code Manually “A service call is just an HTTP request” 26

Human-Readable Documentation Only

Services that don’t describe themselves REST Services “Mashup APIs” “Web APIs” JSON Services “POX” (Plain Old XML) services Human-Readable Documentation Some Manual Work Required 1. Build a URL 2. Make a request 3. Work with request/response data (XML or JSON) 1. Build a URL 2. Make a request 3. Work with request/response data (XML or JSON)

Demo: Demo: Accessing Flickr from Silverlight 29

Manually Issuing Requests Code was exactly as in the regular.NET Framework!  Good news for existing.NET developers Some Silverlight-specific things to be aware of…

Manually Issuing Requests Build a URL What are the allowed protocols? Where can I connect to? Make a Request How do I make a request? Working with Request/Response Data How do I work with XML? How do I work with JSON?

Manually Issuing Requests Build a URL What are the allowed protocols? Where can I connect to? Make a Request How do I make a request? Working with Request/Response Data How do I work with XML? How do I work with JSON?

Allowed URLs HTTP and HTTPS Some restrictions on HTTPS, cross-scheme A few of these will go away after Beta1 Subject to cross-domain rules Must have policy file if not local URL No ftp:// or file:// URLs

Manually Issuing Requests Build a URL What are the allowed protocols? Where can I connect to? Make a Request How do I make a request? Working with Request/Response Data How do I work with XML? How do I work with JSON?

Making HTTP Requests WebClient Simple to use Limited functionality HttpWebRequest Access to all features

Manually Issuing Requests Build a URL What are the allowed protocols? Where can I connect to? Make a Request How do I make a request? Working with Request/Response Data How do I work with XML? How do I work with JSON?

Working with XML XmlReader/XmlWriter Linq to XML XmlSerializer static void w_DownloadStringCompleted(object sender DownloadStringCompletedEventArgs e) { XElement x = XElement.Parse(e.Result); foreach (photo in x.Elements("photo")) { //... } static void w_DownloadStringCompleted(object sender DownloadStringCompletedEventArgs e) { XElement x = XElement.Parse(e.Result); foreach (photo in x.Elements("photo")) { //... }

The JSON Data Format “JavaScript Object Notation” Easy and fast to parse in JavaScript in browsers Often no real reason to use it for SL, except… Reusing existing services built for AJAX pages Smaller message size (but binary XML is a future possibility) Example: {“Person”:{“name”:”john”,”age”:42}}

Approach #3: Use Built-In Classes … for RSS/Atom feeds 39

Consuming Feeds Atom 1.0 Feeds RSS 2.0 Feeds Atom Publishing (Future?) Conform to a Standard Built-in classes to work with such services SyndicationFeed feed = SyndicationFeed.Load(…) foreach (SyndicationItem item in feed) { //Do something with item } SyndicationFeed feed = SyndicationFeed.Load(…) foreach (SyndicationItem item in feed) { //Do something with item }

Demo: Accessing my blogs RSS feeds from Silverlight 41

Syndication Support in Silverlight Protocols RSS 2.0, Atom 1.0 Future possibility: Atom Publishing Protocol Essentially the same as in.NET 3.5 SyndicationFeed, SyndicationItem, etc. Can read / write feeds Subject to same cross-domain restrictions, etc. Use HttpWebRequest/WebClient, then Syndication to parse

Summary: What We Covered Creating Services for Silverlight Creating and consuming WCF services Securing local services Creating public services (safe for cross-domain) Accessing Services that Describe Themselves “Add Service Reference” Accessing Services that Don’t Describe Themselves WebClient / HttpWebRequest, manual work Accessing Feeds RSS/Atom

Resources Silverlight: silverlight.net/blogs/jesseliberty/ timheuer.com/blog/ Personal blogs:

Q&(maybe)A

Gill Cleeren Microsoft Regional Director Microsoft MVP ASP.NET Ordina Belgium Thank you!