Consuming Web Services in Microsoft Silverlight 3

9,463 views

Published on

Come hear how to work with external REST, SOAP, and Windows Communication Foundation (WCF) services from Silverlight. Learn how to securely and efficiently communicate with services using Binary XML, debug services with improved Faults support, and implement server-to-client "push" using the new Add Service Reference for Duplex functionality.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
9,463
On SlideShare
0
From Embeds
0
Number of Embeds
127
Actions
Shares
0
Downloads
113
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Consuming Web Services in Microsoft Silverlight 3

  1. 1. Simple Back-End Data Access WCF, SOAP “Data Push” (Server to Client) WCF Mashups (Using REST APIs) REST, XML/JSON, Atom/RSS
  2. 2. Simple Back-End Data Access WCF, SOAP “Data Push” (Server to Client) WCF Mashups (Using REST APIs) REST, XML/JSON, Atom/RSS
  3. 3. System.ServiceModel.CommunicationException: The remote server returned an error: NotFound
  4. 4. Binary XML
  5. 5. “Silverlight-enabled WCF Service” - now Binary by default
  6. 6. Using quot;typicalquot; message payloads HP BL680c: 8 Intel EMT64 cores@2.4GHz Windows Server 2008 64-bit, IIS7 Text / HTTP Web service requests/sec 24% Binary / HTTP 7570 6122 71% 4615 2702 Your mileage may vary 20 objects 100 objects Message size
  7. 7. Using large messages with arrays of quot;typicalquot; data 40% 34% Size reduction 15% Your mileage may vary String Int Large object graph
  8. 8. Attempt #1: Naïve Approach
  9. 9. Attempt #2: Enable Debugging
  10. 10. Error info still not in Silverlight! System.ServiceModel.CommunicationException: The remote server returned an error: NotFound
  11. 11. HTTP 500 HTTP 200 http://code.msdn.com/SilverlightWS
  12. 12. HTTP 200
  13. 13. With Silverlight 3 Faults Support
  14. 14. Example with Cookies + Forms Auth E.g.: ASP.NET login Credentials User: YourDomain.com Password: Auth info (cookie) Service calls + Auth info Browser
  15. 15. Login through Silverlight Call with credentials to YourDomain.com User: ASP.NET Auth Service Password: ASP.NET Reply contains cookie Auth Service Service calls + Auth info Browser
  16. 16. Using Windows Authentication Windows login User: YourDomain.com Password: Service calls + Creds Browser
  17. 17. Cross-Domain Threat MyBank.com Login Credentials User: MyBank.com Password: Auth info (e.g. cookie) Could steal or change data Malicious call + Auth info if protection wasn’t in place Malicious application EvilApps.com
  18. 18. Identity managed by Silverlight, not the Browser YourDomain.com User: Password: Creds are added by Silverlight, not browser No creds EvilApps.com Browser
  19. 19. [OperationContract] public decimal GetAccountBalance (int accountID, string userName, string password);
  20. 20. <!-- WS-Security Header --> <!-- With UserName, Password, Timestamp --> <!-- Message Payload --> Default max skew is 5 minutes – may require changes (Client clock can’t be more that 5 minutes out of sync with server)
  21. 21. sl
  22. 22. Simple Back-End Data Access WCF, SOAP “Data Push” (Server to Client) WCF Mashups (Using REST APIs) REST, XML/JSON, Atom/RSS
  23. 23. EndpointAddress address = new EndpointAddress(quot;http://example.com/Service1.svcquot;); CustomBinding binding = new CustomBinding( new PollingDuplexBindingElement(), new TextMessageEncodingBindingElement( MessageVersion.Soap12WSAddressing10, Encoding.UTF8), new HttpTransportBindingElement());
  24. 24. CallbackContract=… IsOneWay=true GetCallbackChannel
  25. 25. Simple Back-End Data Access WCF, SOAP “Data Push” (Server to Client) WCF Mashups (Using REST APIs) REST, XML/JSON, Atom/RSS
  26. 26. HTML DOM + JavaScript XmlHttpRequest Proxied through a Service
  27. 27. “Paste XML as Serializable Types”
  28. 28. Simple Back-End Data Access WCF, SOAP “Data Push” (Server to Client) WCF Mashups (Using REST APIs) REST, XML/JSON, Atom/RSS
  29. 29. Your feedback is important!
  30. 30. © 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.
  31. 31. High-level components and User Code HttpWebRequest Browser Plugin APIs Restrictions Web Browser - Cookies - Authenticated sessions Restrictions - Caching - Proxy server to use Windows/Mac Networking Layer
  32. 32. Client Client Any messages? Server Server App Duplex Duplex App Channel 10-15sec Channel No messages Any messages? Message Message Message Any messages? Client Browser Server

×