Presentation is loading. Please wait.

Presentation is loading. Please wait.

Douglas Boling President Boling Consulting Inc. WEM202.

Similar presentations


Presentation on theme: "Douglas Boling President Boling Consulting Inc. WEM202."— Presentation transcript:

1

2 Douglas Boling President Boling Consulting Inc. WEM202

3 Speaker Douglas Boling Author – Programming Microsoft Windows CE 4th Edition Trainer – Classes on Windows CE App Development Windows CE OAL Development.NET Compact Framework Consultant – Work with companies to help their Windows CE application and platform development efforts

4 Agenda Introduction to Web Services Implementing a Web Service Client Understanding RSS Feeds Connecting the Picture Frame

5 Agenda Introduction to Web Services What is a web service Desktop/Server support Tools to write web service clients Implementing a Web Service Client Understanding RSS Feeds Connecting the Picture Frame

6 What is a Web Service? Web services are ‘programmatic’ web sites Using the web w/o “screen scraping” RPC protocol using port 80 Uses “SOAP” Simple Object Access Protocol All data transmitted as strings

7 Server side Microsoft support via ASP Simple to implement with ASP.NET Client side Simple to implement via.NET framework Native clients implemented with ATL Desktop/Server Support

8 Visual Studio provides support Server side Client side.NET commonly used for both sides Native implementations can work Client – ATL sample today Server – Mike Hall example on CE http://blogs.msdn.com/mikehall/archive/2007/10/10/buil ding-xml-web-services-for-windows-embedded-ce-6- 0.aspx Tools To write Web Service Clients

9 Writing a Web Service Simple, with ASP.NET First example… Add two numbers VS 2005/2008 caution Defaults to Local Development Server Services can’t be seen by CE devices/emulators IIS configuration difficult!

10 Agenda Introduction to Web Services Implementing a Web Service Client Native Managed Understanding RSS Feeds Connecting the Picture Frame

11 Native Web Service Client Start with a simple device application Add ATL support Allow single threads in MTA Increase stack size

12 Native Web Service Client Add Web Reference Include webref.h in stdafx.h Create web client class Call method

13 A Managed Web Service Client Simple.NET Windows Forms App Add web reference “New up” the web reference object Call methods

14 Web Services Douglas Boling President Boling Consulting Inc.

15 Agenda Introduction to Web Services Implementing a Web Service Client Understanding RSS Feeds Connecting the Picture Frame

16 Project Create a picture frame that connects to web Change of plans… Use RSS instead of Web Service

17 New Project Web based pictures at FrameIt.Com Part of Windows Live Services Use RSS feed to query pictures Download and display pictures

18 RSS – “Really Simple Syndication” Web feed format for frequently updated content XML document describes feed content Many readers available We’re going to write a trivial one here

19 Example RSS XML Feed <rss version="2.0“ xmlns:frameit="http://www.frameit.live.com/firss/" xmlns:media="http://search.yahoo.com/mrss/"> 287 DemoCollection http://frameit.live.com Tue, 12 May 2009 13:14:49 -0700 Tue, 12 May 2009 14:27:19 -0700 …

20 Example RSS XML Item xxxxx Custom Windows Live Photos Paris http://0mxaeg.blu.live/…/DSCN0360.JPG Paris http://0mxaeg.blu.live/…/DSCN0360.JPG

21 Example RSS XML Item (2) <![CDATA[ <img src= "http://0mxaeg.blu.live/…/DSCN0360.JPG“ /> ]]> Mon, 30 Mar 2009 17:30:42 -0700 <enclosure type="image/jpeg“ url="http://0mxaeg.blu.live/…/DSCN0360.JPG" /> <media:content type="image/jpeg" url="http://0mxaeg.blu.live/…/DSCN0360.JPG" />

22 Agenda Introduction to Web Services Implementing a Web Service Client Understanding RSS Feeds Connecting the Picture Frame Native Managed

23 Tasks of Native Application Connect to RSS feed Download XML describing feed Parse XML Download images

24 Connecting Using WinINet WinINet library provides higher level access to web APIs for Initialize the library Connect to server Download file

25 Initializing WinINet To initialize WinINet call InternetOpen Parameters: AgentString to indicate client type Access typeIndicates proxy or direct connect Proxy NameName of proxy server Flags

26 Connecting to a Server To connect to a server, use InternetConnect Parameters: lpszServerNameName of server nServerPortPort to connect lpszUserNameOptional user name lpszPasswordOptional password dwServiceHTTP or FTP A few others…

27 Reading A File Use the following functions HttpOpenRequest HttpAddRequestHeaders HttpSendRequest If successful, loop on HttpQueryInfo InternetQueryDataAvailable InternetReadFile

28 Native Picture Frame RSS Reader Code Douglas Boling President Boling Consulting Inc.

29 Picture Frame in Managed Code Managed code much simpler than native Use WebRequest class to read data Use XMLReader to parse the RSS XML Use PictureBox to display image

30 Download A File // Compose the request WebRequest request=WebRequest.Create ("http://parisfeed.frameit.com"); WebResponse response = request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); string strXMLFeed = sr.ReadToEnd(); response.Close(); // Write the string into a file StreamWriter sw = new StreamWriter(strXMLFile); sw.Write(strXMLFeed); sw.Close();

31 Parse The Feed XmlTextReader reader = new XmlTextReader(strFilename); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "enclosure“) { if (reader.AttributeCount > 0) { strURL = reader.GetAttribute("url"); if (null != strURL) ar.Add(strURL); } break; }

32 Managed Frame RSS Reader Code Douglas Boling President Boling Consulting Inc.

33 Summary Web services client support available in Windows Embedded CE Managed much easier than native RSS feeds aren’t that difficult Again… Managed much easier than native

34 dboling@bolingconsulting.com

35 Windows Embedded Resources Website: www.windowsembedded.com Social Channels: Social Channels: blogs.msdn.com/mikehallblogs.msdn.com/obloch Technical Resources: http://msdn.microsoft.com/embedded Tools evaluations: www.windowsembedded.com/downloads

36 www.microsoft.com/teched Sessions On-Demand & Community http://microsoft.com/technet Resources for IT Professionals http://microsoft.com/msdn Resources for Developers www.microsoft.com/learning Microsoft Certification and Training Resources www.microsoft.com/learning Microsoft Certification & Training Resources Resources

37 Complete an evaluation on CommNet and enter to win!

38 © 2009 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.


Download ppt "Douglas Boling President Boling Consulting Inc. WEM202."

Similar presentations


Ads by Google