Tagged with WCF
Today I was working with a client and ran into a problem I didn't expect. This particular problem had to do with Silverlight consuming a WCF Service. Sometimes WCF causes me to spew four letter words. There is a class of WCF problems that cause this: connection rejection. WCF has been designed to prevent common DDoS and other attacks that could cause servers to fail or at least not serve honest requests. To this end the default size of a request is quite small. In fact, its usually 64K in size. This size is fine for most every request but occassionally when a client wants to send a collection of things to the server this size is too small. But we'll get to that in a minute. First, some background...
This particular client has a large service that's been working for quite a while, then suddenly a single call he has was being rejected. The new service call he was making was sending back a list of a couple of hundred of POCO classes. He had been downloading large lists before so on the surface this should have worked. But it didn't.
The cause was that the default WCF limits were rejecting the connection. This type of error where its just failing, even Fiddler isn't helpful. There is no return code, the connection is just severed. Debugging it requires some trial and error which sucks. The calls that were returning a lot of data were working fine because the default ClientConfig file looks like this:
If you've never had the chance to visit my sister site (http://www.silverlightdata.com), now's a good time. I've updated my examples there to include my MVVM, Prism and Declarative UI examples (to go with the skinning/switchable Astoria example). Take a look if you're doing Silverlight data-based applications.
If you have spent anytime with Silverlight, you've likely run across the cross-site scripting issue. Essentially, the browser doesn't let you do web requests from other sites than the one you're hosted in. This is to prevent nasty script kiddies from doing nefarious things.
While I hope that Microsoft solves this in the way that Flash does (essentially a white-list that is located on the server that says what sites are ok), I do suggest a workaround: proxy calls offsite through your server. You can create a simple service on your site that returns data from another site. Then in Silverlight its a matter of making a request up to your own server to get the data and work with it in whatever way you want.
Luckily with .NET 3.5 and WCF's new REST stack, this is really easy. For example, here is a simple WCF service using the new WebGet attribute to specify that it can be called like a REST service:
I am delving into WCF and AJAX (not at the same time) lately so I wanted to see if they were compatible. According to this whitepaper on ASP.NET (follow the link and scroll down to "Support for WCF Web Services"), the RTM of AJAX does not support WCF. It seems they removed it so they could make it work better in a later release. The promise is that by the Orcas release of VS, they will be compatible.
This further cements my opinion that releasing .NET 3.0 without FULL tool and compatibility is nonsense. Without a good across the platform support (e.g. WCF and ASP.NET stack working well together), a workable WPF editor (Cider is horribly broken currently...change the default editor for XAML to XML, you'll be happier), and projects that actually compile out of the box (WPF projects don't compile currently without some hand-editing of the XAML). Microsoft has always been about tools more than technology, that's why I've been with them so long. If we need to cruft together a bunch of installs to make stuff work, I'd be doing that in Java and Linux.
NOTE: No WCF Designer in this drop and Cider (the WPF designer) doesn't work in VS Express.
The PDC talk is heating up and it is clear to me that there is a huge number of 'wow' features that will be unveiled in LA. It seems like most of the other bloggers are talking about what I think is protected behind the multitude of NDA's I've signed. So to be safe I am keeping my mouth shut...tightly. What I can say is that what you'll see at the show about Whidbey, Yukon and Longhorn are phenomenal. Some of it is evolutionary, but much of it is revolutionary. I think you’ll be pleased... I am.
Since Don (Box) can’t seem to not talk about it, Indigo has gotten me really intrigued. I haven’t seen any of it, but I really want to know everything I can about it. That’s where I will spend my time at the PDC.
On a more mundane note, it looks INETA is going to be fielding its own band at the PDC. So far I know its Richard Hale Shaw, Carl Frankin and I. But I expect it to be a blast a number of people to come out of the woodwork to play.