locked
WCF Data Service - OData - RSS - confusion :/ RRS feed

  • Question

  • Hi

    I'm trying to understand WCF Data Services.

    From what I can see WCF Data Services produces OData. Is this correct?

    What I would like is a WCF service that outputs an RSS feed, but the only one I can see that does that is a Workflow service (I'm using .net 3.5 sp 1).

    Or is it possible to output RSS from WCF Data Services? If so, how?

    Thursday, July 22, 2010 9:29 AM

Answers

  • Hi,

    If you just want ATOM/RSS, then Syndication API is the way to go (http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx). You can then host a simple WCF REST end point and return the result of the syndication API serialization from it.

    Note that you need to create the output in terms of the syndication API objects (Create an in-memory tree of syndication objects), which you then write out as either RSS or ATOM.

    You can do something like that with WCF Data Services (ATOM only though), but it will also allow querying. So the client doesn't have to download the whole feed, it can ask for only parts of it, filter, sort, and so on. Depends on your needs.

    The way to customize the ATOM in WCF Data Services if you have just classes is very simple, you put attributes on your classes which map certain properties to specific places in the ATOM payload. The attribute is EntityPropertyMappingAttribute (http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx). It is also described in the link I provided in the earlier post. Note that it does NOT require usage of entity framework.

    Thanks,


    Vitek Karas [MSFT]
    Friday, July 23, 2010 12:05 PM
    Moderator

All replies

  • Hi,

    WCF Data Services produces OData. OData right now defines two possible formats, ATOM and JSON. We don't support RSS right now, but given that ATOM is very similar, you might be able to use that instead. If that's the case take a look at feed customization which allows you to tweak the ATOM output in a way more appropriate for your data. http://msdn.microsoft.com/en-us/library/ee373839.aspx

    Thanks,


    Vitek Karas [MSFT]
    Thursday, July 22, 2010 9:39 AM
    Moderator
  • Ok thanks.

     

    Atom and RSS and very much alike - so thats fine. 

    So, and excuse me asking what is probably a simple question - but I'm a WCF Data Service newbie - but how do I set the service to output Atom?

     

    Thanks again.

     

    Update - Ok I see on MSDN that the WCF Data Service outputs atom by default.

    My real question then is how do I asign my data values to the Atom fields? For example, how Atom has Title, Author etc, how can I give my values to these nodes?

     

    From the tutorials I have read that seems to happen automagically - how can this be controlled?

    • Edited by Magick93 Thursday, July 22, 2010 10:43 AM figured something out
    Thursday, July 22, 2010 10:37 AM
  • Please look at the link that Vitek provided above. That shows you how to customize feeds according to your needs. It does not happen out of the box. You need to set the appropriate attributes (either on the type or in the csdl or via metadata api's) depending on which provider you are using.

    Hope this helps.

    Thanks

    Pratik


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, July 22, 2010 5:39 PM
    Moderator
  • Ok, maybe I'm trying to get WCF Data Services to do something its not really designed to do.

     

    I just want to make an RSS feed. I'm not using the Entity Framework for this, and feel that it will over complicate things - and add too much time - to create a custom Entity Framework Provider. Im just using some custom classes. After reading the link that Vitek posted, I have the impression that its overly complicated.

    Is there another WCF template that is more suited to RSS/Atom?

    Friday, July 23, 2010 8:31 AM
  • Hi,

    If you just want ATOM/RSS, then Syndication API is the way to go (http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx). You can then host a simple WCF REST end point and return the result of the syndication API serialization from it.

    Note that you need to create the output in terms of the syndication API objects (Create an in-memory tree of syndication objects), which you then write out as either RSS or ATOM.

    You can do something like that with WCF Data Services (ATOM only though), but it will also allow querying. So the client doesn't have to download the whole feed, it can ask for only parts of it, filter, sort, and so on. Depends on your needs.

    The way to customize the ATOM in WCF Data Services if you have just classes is very simple, you put attributes on your classes which map certain properties to specific places in the ATOM payload. The attribute is EntityPropertyMappingAttribute (http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed.aspx). It is also described in the link I provided in the earlier post. Note that it does NOT require usage of entity framework.

    Thanks,


    Vitek Karas [MSFT]
    Friday, July 23, 2010 12:05 PM
    Moderator