DCSIMG
December 2009 - Posts - Ido Flatow's Blog Veni Vidi Scripsi

Ido Flatow's Blog

Veni Vidi Scripsi

News

Have you heard me speak?
Powered
<style type='text/css' media='screen' id='sm_css'> #smix {overflow: visible;height: auto;border-radius: 10px;max-width: 250px;background-color: #323232;text-align: left;font-size: 12px;line-height: 16px;font-family:'Lucida Sans Unicode','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;-webkit-border-radius: 10px;-moz-border-radius: 10px;border-radius: 10px;} #smix a {color: #0056CC;text-decoration: none;} #smix .sm_head {color: #fff; line-height: 1em;font-size: 1.4em;padding: 10px;color: #fff;} #smix .sm_lanyard_wrapper {background-color: #fff;;clear: both;width: 97%;margin: 0 auto;margin-bottom: 0px;} #smix .sm_lanyard_content {padding: 7px;}#smix button.sm_rec, #smix a.sm_rec, #smix input[type=submit].sm_rec { padding: 6px 10px; -webkit-border-radius: 2px 2px;-moz-border-radius: 2px; border-radius: 2px; border: solid 1px rgb(153, 153, 153); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221))); color: #333; text-decoration: none; cursor: pointer; display: inline-block; text-align: center; text-shadow: 0px 1px 1px rgba(255,255,255,1); line-height: 1; }#smix .sm_rec:hover { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(248, 248, 248)), to(rgb(221, 221, 221))); }#smix .sm_rec:active { background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(204, 204, 204)), to(rgb(221, 221, 221))); }#smix .sm_rec.medium { padding: 3px 7px; font-size: 13px; }#smix .sm_rec span.icon.thumbs_up {background-position: 0px 36px;vertical-align: text-top;display: inline-block;margin-right: 4px;height: 18px;width: 16px;background-image: url(http://speakermix.com/images/new/thumbsold.png);}#smix .sm_rec:hover span.icon.thumbs_up {background-position: 0px 18px;} #smix .sm_events {padding:2px 0px 4px 0px;} #smix .sm_section {font-size: 10px; border-bottom: 1px solid silver; margin-bottom: 6px;} #smix .sm_subline {font-size:120%;margin-top:4px;font-weight:bold} #smix .powered {text-align: right} #smix .powered img {margin: 7px} </style>
Sela Technology Center

Advertisement

December 2009 - Posts

Communicating From Silverlight 4 – My session at the SDP

Today at the SDP I gave a lecture on the different ways we can communicate with the web from Silverlight 4. We talked about the different HTTP Stacks Silverlight offers and the many communication types & technologies you can use, such as:

  • Simple http requests
  • Restful services
  • Syndication (Rss/Atom) feeds
  • ASMX Web Services
  • WCF services
  • WCF Data Services
  • TCP communication
  • UDP communication

Yes, you can do all the above with Silverlight 4 !

In addition, we talked about different WCF scenarios that you can achieve in Silverlight 4, such as:

  • Binary message encoding
  • Catching SOAP Faults
  • Passing HTTP & SOAP Headers
  • Authentication
  • Using Duplex

You can download the presentation and the code samples from here.

The lecture’s recording will be available from the SDP site in a few days, so stay tuned…

My ORM presentation at SDP (Sela Developer Practice)

Just finished passing my presentation about ORM & Entity Framework basics

This presentation is part of a whole-day seminar about ORM Tools & Concepts

Currently Bernie & Erez are demonstrating NHibernate & Entity Framework head-to-head and later on Gil will deep dive into Entity Framework and Erez & Bernie will once again join forces to talk about Data Access Pattern in the real world.

We’ll finish the day with an Expert Panel, where Oren Eini will join us to talk about ORMs, NHibernate, Entity Framework, Pattern, Tips & Tricks and more.

Be sure to download the presentation from our blogs. Video recordings will be available after the SDP.

Handling SOAP Faults In Silverlight

In the past, when we tried to connect from Silverlight 2 to WCF Services that threw exceptions (every now and then), we got the famous “Not found” Communication Exception.

The reason we didn’t get a SOAP Fault is that WCF returns SOAP Fault responses with a HTTP code of 500 – this is according to SOAP protocol, but the browser doesn’t allow 500 responses to be returned to Silverlight – it replaces them with a CommunicationException and thus hides the real fault that returned.

When we moved to Silverlight 3, Microsoft published the following article, describing how to workaround the browser’s block, using a Message Inspector in the WCF-side to replace HTTP 500 fault responses with a HTTP 200 fault responses, thus allowing Silvelright to get these messages.

But… this fix will make your WCF service not compatible with the SOAP protocol, not mentioning you’ll have a whole new inspector to manage (test, debug, maintain…), and you’re debug skill will need to improve (try using fiddler to find these errors when the return code is 200 and not 500 – no red lines !!).

There is another solution that isn’t discussed much, and doesn’t require making any changes in WCF – changing the HTTP Stack Silvelright uses for the services.

In Silverlight 3 a new HTTP Stack was released – the Client HTTP Stack. The Client Stack uses the OS directly to create network operations, instead of using the browser. The new stack can be used instead of the Browser’s HTTP Stack for http and https. There are some differences between the stacks, one of them being the Client’s stack ability to handle all types of responses, including HTTP 500 responses.

To use the Client Stack for a specific service, just add the following code at the beginning of your Silverlight application (just change the url):

HttpWebRequest.RegisterPrefix(http://localhost/services/serviceX,
WebRequestCreator.ClientHttp);

 
The above line of code will tell Silverlight to use the Client stack whenever a call is made to a URL with that prefix – all other calls will use the Browser stack. If you want all calls to go through the Client stack, use a prefix of “http://”

You can read more about the ClientHttp class here, or just come to the SDP (registration required), where I will talk about the Client stack and other changes made in Silverlight 3 & Silverlight 4 that improves Silverlight’s ability to use network resources.

There are going to be many cool stuff in the SDP lectures, straight from the PDC, I myself still haven’t decided which lectures to go to (WCF 4? ASP.NET 4? WF? many to choose from).