Mike Taulty DevDays 2010 Silverlight 4 Networking

Preview:

DESCRIPTION

 

Citation preview

Change the Rules

Silverlight 4 – Networking

Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty

browser launched, rich internet apps

have limited local access

files hardware

software ...

different types of Silverlight 4 apps

rich, controlled network access is key

firewall

being network aware is useful

all network access is asynchronous

your code not your code

network stack sketch

lots of capabilities to choose from

• network protocols – HTTP, TCP, UDP

• data encodings – text, binary

• data serialization – XML, JSON, RSS, ATOM

• messaging protocols – SOAP, REST, OData

• messaging patterns – request response, duplex, multicast

• programming models – raw HTTP, WCF, WCF Data Services, sockets

• security – cross-site, authentication, cross-scheme

and two key classes for HTTP itself

• WebClient – simple, easier to use

• (Http)WebRequest – more functionality, slightly more complex code

cross-domain security policy

there are two http stacks

verbs: GET, POST automatic cookie management ( restricted ) set of request headers automatic authentication status codes: LIMITED ( 200, 400 )

verbs: ALL manual cookie management ( restricted ) set of request headers response headers & body authentication ( code & automatic ) status codes: ALL

switching between stacks

Change the Rules

demo reaching out with HTTP

lots of capabilities to choose from

• network protocols – HTTP, TCP, UDP

• data encodings – text, binary

• data serialization – XML, JSON, RSS, ATOM

• messaging protocols – SOAP, REST, OData

• messaging patterns – request response, duplex, multicast

• programming models – raw HTTP, WCF, WCF Data Services, sockets

• security – cross-site, authentication, cross-scheme

sockets

• support for streaming TCP sockets – Silverlight is a socket client, not a server – consider WCF netTCP as a better option

• security – limited to ports 4502 to 4534 – policy file authorisation required - HTTP or TCP download – these restrictions do not apply to trusted applications

sockets

• support for multicast UDP sockets – both single source & any source multicasting

• programmability is via – Udp[Single/Any]SourceMulticastClient classes

• security – port numbers must be above 1024

– policy file authorisation required – UDP download

– these restrictions do not apply to trusted applications

multicast security

for any source multicasting, the Silverlight client multicasts to the multicast group on port 9430 and waits for an authorisation

Change the Rules

demo reaching out with sockets

lots of capabilities to choose from

• network protocols – HTTP, TCP, UDP

• data encodings – text, binary

• data serialization – XML, JSON, RSS, ATOM

• messaging protocols – SOAP, REST, OData

• messaging patterns – request response, duplex, multicast

• programming models – raw HTTP, WCF, WCF Data Services, sockets

• security – cross-site, authentication, cross-scheme

WCF subset in Silverlight for HTTP/TCP

• transports - HTTP(S) and TCP • encodings - text and binary • serialization - DataContract* & XmlSerializer* • protocols - WS-I Basic Profile 1.1

– XML, HTTP, SOAP and WSDL – SOAP 1.2, WS-Addressing 1.0, WS-Security*

• patterns - req/resp, duplex*, polled duplex* • privacy - HTTPS • authN - transport or message credential • faults - only available on the client stack

Change the Rules

demo reaching out with WCF via HTTP/TCP

lots of capabilities to choose from

• network protocols – HTTP, TCP, UDP

• data encodings – text, binary

• data serialization – XML, JSON, RSS, ATOM

• messaging protocols – SOAP, REST, OData

• messaging patterns – request response, duplex, multicast

• programming models – raw HTTP, WCF, WCF Data Services, sockets

• security – cross-site, authentication, cross-scheme

RESTful services ( generically )

Resources

Res 1

Res 2

Res 3

Res 4

HTTP Request URL

VERB Payload

HTTP Response

Status

GET POST PUT

DELETE XML JSON

Payload

XML JSON

RESTful services ( more specifically )

• Open Data Protocol ( odata ) – www.odata.org

– published under the Open Specification Promise

• Extends the AtomPub standard to add – an addressing scheme

– a mechanism for schema

– alternate representation – JSON

– handling for concurrent updates

– handling for batched requests

WCF Data Services ( “Astoria” )

• implementation of odata for the client and the server

http://server/customers(‘alfki’)/Orders?$top=20

Change the Rules

demo reaching out with WCF Data Services

resources

• Channel 9 Silverlight 4 MEF Screencasts

– channel9.msdn.com/tags/SL4Networking

• Silverlight .NET

– www.silverlight.net

thank you for coming – please provide feedback

Change the Rules

Silverlight 4 – Networking

Mike Taulty, Microsoft UK mtaulty@microsoft.com mtaulty.com @mtaulty

Recommended