Exposing/Consuming RSS/ATOM using WCF 3.5 & Silverlight 2
- Posted: Apr 11, 2008 at 1:40 PM
- 6,129 Views
- 8 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
I don't think there is necessarily a right or wrong answer here. I think it is a bit of a stretch to suggest I have declared request improperly. It would be more accurate to say that I have declared request in a way that you dislike for valid reasons. You make some really good points about the side effects of using var. I appreciate you making these points because it is very important for people to understand the side effects you mention. Unfortunately, I can't cover every detail about all the technology in use in a screencast/demo. If I did, the screencast would have been at least twice as long:).
You may be right about laziness. I find myself using var in a number of scenarios I suspect you would dislike. Maybe I am using it so much because I’ve done quite a bit of JavaScript/AJAX programming of late and it has become a habit. Who knows? I think one could argue a number of technologies such as intellisense, code snippets, and many more have made me a lazier programmer over the years. I surely know that I can't code in notepad or vi like I used to because of my dependency on both IDE and language features. Then again, it is also fair to say that the productivity gains outweigh the dependency on the features.
With the var keyword, it seems the documentation at http://msdn2.microsoft.com/en-us/library/bb383973.aspx would somewhat support your statements since it says “It is recommended to use var only when it is necessary, that is, when the variable will be used to store an anonymous type or a collection of anonymous types.” However, like any documentation, it is a recommendation. I still believe the use of var is a matter of preference. Am I misusing the var keyword? That’s in the eye of the beholder. I know where you stand:).
Having said that...
var request = new WebClient();
?? Way to promote terrible programming practices.
You can see http://msdn2.microsoft.com/en-us/library/bb383973.aspx for more details.
Personally, I think using the var keyword is a matter of preference, but not a terrible programming practice as you suggest. The beauty is that the following two lines of code are identical to the compiler:
var request = new WebClient();
WebClient request = new WebClient();
The reason I dislike it is because I believe it promotes laziness and needlessly obfuscates the code. The difference between var request = new WebClient(); and WebClient request = new WebClient(); is negligable, so why not declare it properly?
Take these examples:
var provider = providerFactory.Create();
var customer = base.CreateCustomer();
As a developer seeing this code for the first time, what type is provider/customer? The only way of knowing is by looking up the declaration of Create/CreateCustomer. For the sake of a few keystrokes, you have made the code considerably harder to maintain.
Additionally, the general argument for var seems to be that the compiler and VS intellisense will inferring the type for you, but that doesn't help me if I am viewing it outside devenv (eg. comparing two versions of a source file in subversion).
I need to create a custom RSS feed which would access a bunch of sales data from the database and consume from my silverlight 3 app. I followed your video. Everything works fine when I run from within the syndication library project. But when I try to consume the feed from silverlight app, it just doesn't seem to work. I get System.Security.SecurityException. So I placed the clientaccesspolicy xml at the silverlightapp.web project. Still doesn't seem to work. Do I need to host this syndication library on IIS? By default, it seems to be self hosted and I see that in your demo, you are hosting your feed on feedburner. Do I need to create silverlight enabled WCF somehow? Also, I was wondering about the "Design_Time_Addresses" in the generated url - http://localhost:8731/Design_Time_Addresses/myLibrary/Feed1/ ?
Thanks in advance...
How do you expose your RSS feeds Created in Video on IIS 6. In our case we have IIS6 with https as protocol. How can we expose the RSS feed so user can trype some thing like this https://www.test.com/Design_Time_Addresses/myLibrary/Feed1/ and gets the Rss feed?
@keydet: Ahh help! This tutorial was sooooo close to a problem I am trying to solve. You built the WCF service to return the AtomFeedFormatter (or RSS) types. PERFECT. You created a Silverlight control to get the RSS. PERFECT. However, your code example does not consume the WCF service to call the 'CreateFeed()' method. You hardcoded calling the RSS feed URL directly in your Silverlight sample control and bypassed the WCF service.
I have a WCF service my Silverlight app is consuming almost identical to yours. The problem is when consuming the WCF service, the wired up 'Completed' event in the Silverlight control that calls the WCF method, gets back CompletedEventArgs of type 'ArrayOfXElement' which is a list of System.Xml.Linq.XElement objects. This is the type that is translated from the serialized feed returned from WCF via the AtomFeedFormatter return type. How in the heck do I get e.Result of type ArrayOfXElement back into a SyndicationFeed or SyndicationItem object??
I bet if you consumed your WCF service you created instead of calling that hardcoded URL in your Silverlight control, you would have the same issue. And you can NOT override the type returned in the 'Advanced' properties upon consuming the WCF service. Regardless of type selected (ObservableCollection for example) the AtomFeedFormater type returned from WCF gets translated into an ArrayOfXElement.
How do I get this ArrayOfXElement type back into a SyndicationFeed, so I too can bind it to my .ItemsSource() property on my Silverlight control??
Thank you!!
Remove this comment
Remove this thread
close