1 / 38

Building a Picture Frame, Part 3: Connect a Windows Embedded CE Device to Web Services

Building a Picture Frame, Part 3: Connect a Windows Embedded CE Device to Web Services. Douglas Boling President Boling Consulting Inc. WEM202. Speaker. Douglas Boling Author – Programming Microsoft Windows CE 4th Edition

carlow
Télécharger la présentation

Building a Picture Frame, Part 3: Connect a Windows Embedded CE Device to Web Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building a Picture Frame, Part 3: Connect a Windows Embedded CE Device to Web Services Douglas Boling President Boling Consulting Inc. WEM202

  2. 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

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

  4. 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

  5. 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

  6. Desktop/Server Support • 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

  7. Tools To write Web Service Clients • 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/building-xml-web-services-for-windows-embedded-ce-6-0.aspx

  8. 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!

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

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

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

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

  13. demo Web Services Douglas Boling President Boling Consulting Inc.

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

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

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

  17. 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

  18. Example RSS XML Feed <?xmlversion="1.0"encoding="utf-8"?> <rssversion="2.0“ xmlns:frameit="http://www.frameit.live.com/firss/" xmlns:media="http://search.yahoo.com/mrss/"> <channel> <ttl>287</ttl> <title>DemoCollection</title> <link>http://frameit.live.com</link> <generator>http://frameit.live.com</generator> <lastBuildDate>Tue, 12 May 2009 13:14:49 -0700 </lastBuildDate> <pubDate>Tue, 12 May 2009 14:27:19 -0700</pubDate> <description></description> <item>…</item> <item>…</item> <item>…</item> </channel>

  19. Example RSS XML Item <item> <frameit:sourceIcon>xxxxx</frameit:sourceIcon> <frameit:sourceCategory>Custom</frameit:sourceCategory> <frameit:sourceName>Windows Live Photos </frameit:sourceName> <title>Paris</title> <link>http://0mxaeg.blu.live/…/DSCN0360.JPG</link> <category>Paris</category> <guidisPermaLink="true"> http://0mxaeg.blu.live/…/DSCN0360.JPG</guid>

  20. Example RSS XML Item (2) <description><![CDATA[ <imgsrc= "http://0mxaeg.blu.live/…/DSCN0360.JPG“ /><br/>]]></description> <pubDate>Mon, 30 Mar 2009 17:30:42 -0700</pubDate> <enclosuretype="image/jpeg“ url="http://0mxaeg.blu.live/…/DSCN0360.JPG" /> <media:contenttype="image/jpeg" url="http://0mxaeg.blu.live/…/DSCN0360.JPG" /> </item>

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

  22. Tasks of Native Application • Connect to RSS feed • Download XML describing feed • Parse XML • Download images

  23. Connecting UsingWinINet • WinINet library provides higher level access to web • APIs for • Initialize the library • Connect to server • Download file

  24. Initializing WinINet • To initializeWinINet call InternetOpen • Parameters: • Agent String to indicate client type • Access type Indicates proxy or direct connect • Proxy Name Name of proxy server • Flags

  25. Connecting to a Server • To connect to a server, use InternetConnect • Parameters: • lpszServerNameName of server • nServerPort Port to connect • lpszUserNameOptional user name • lpszPasswordOptional password • dwService HTTP or FTP • A few others…

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

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

  28. 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

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

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

  31. demo Managed Frame RSS Reader Code Douglas Boling President Boling Consulting Inc.

  32. 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

  33. question & answer dboling@bolingconsulting.com

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

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

  36. Complete an evaluation on CommNet and enter to win!

  37. © 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.

More Related