Architecture of Syndication
The Syndication API is designed to provide a format-neutral programming model that allows syndicated content to be written on to the wire in a variety of formats. The abstract data model consists of the following classes:
These classes map closely to the constructs defined in the Atom 1.0 specification, although some of the names are different.
In Windows Communication Foundation (WCF), syndication feeds are modeled as another type of service operation, one where the return type is one of the derived classes of SyndicationFeedFormatter. The retrieval of a feed is modeled as a request-response message exchange. A client sends a request to the service and the service responds. The request message is set over an infrastructure protocol (for example, raw HTTP) and the response message contains a payload that consists of a commonly understood syndication format (RSS 2.0 or Atom 1.0). Services that implement these message exchanges are referred to as syndication services.
The contract for a syndication service consists of a set of operations that returns an instance of the SyndicationFeedFormatter class. The following example demonstrates an interface declaration for a syndication service.
[ServiceContract]
[ServiceKnownType(typeof(Atom10FeedFormatter))]
[ServiceKnownType(typeof(Rss20FeedFormatter))]
public interface IBlog
{
[OperationContract]
[WebGet(UriTemplate="GetBlog?format={format}", BodyStyle=WebMessageBodyStyle.Bare)]
SyndicationFeedFormatter GetBlog(string format);
}
Syndication support is built on top of the WCF REST Programming Model that defines the WebHttpBinding binding, which is used in conjunction with WebHttpBehavior to make feeds available as services. For more information about the WCF REST Programming Model, see WCF REST Programming Model Overview.
Note
The Atom 1.0 specification allows for fractional seconds to be specified in any of its date constructs. When serializing and deserializing the WCF implementation ignores the fractional seconds.
Object Model
The object model for syndication consists of the groups of classes in the following tables.
Formatting Classes:
Class | Description |
---|---|
A class that serializes a SyndicationFeed instance to Atom 1.0 format. |
|
A class that serializes SyndicationFeed derived classes to Atom 1.0 format. |
|
A class that serializes a SyndicationItem instance to Atom 1.0 format. |
|
A class that serializes SyndicationItem derived classes to Atom 1.0 format. |
|
A class that serializes a SyndicationFeed instance to RSS 2.0 format. |
|
A class that serializes SyndicationFeed derived classes to RSS 2.0 format. |
|
A class that serializes a SyndicationItem instance to RSS 2.0 format. |
|
A class that serializes SyndicationItem derived classes to RSS 2.0 format. |
Object Model Classes:
Class | Description |
---|---|
SyndicationCategory |
A class that represents the category of a syndication feed. |
A base class that represents syndication content. |
|
A class that represents a syndication element extension. |
|
A collection of SyndicationElementExtension objects. |
|
SyndicationFeed |
A class that represents a top-level feed object. |
SyndicationItem |
A class that represents a feed item. |
SyndicationLink |
A class that represents a link within a syndication feed or item. |
SyndicationPerson |
A class that represents an Atom Person construct. |
A class that represents the supported syndication protocol versions. |
|
A class that represents any SyndicationItem content to be displayed to an end user. |
|
An enumeration that represents the different types of text syndication content supported. |
|
A class that represents syndication content that consists of a URL to another resource. |
|
A class that represents syndication content that is not to be displayed in a browser. |
The core data abstractions in the object model are Feed and Item, which correspond to the SyndicationFeed and SyndicationItem classes. A Feed exposes some feed-level metadata (for example, Title, Description, and Author), a location to store unknown extensions, and a set of items that make up the rest of the feed's information content. An Item makes available some item-level metadata (for example, Title, Summary, and PublicationDate), a location to store unknown extensions, and a content element that contains the rest of the item's information content. The core abstractions of Feed and Item are supported by additional classes that represent common data constructs referenced in the Atom 1.0 and RSS specifications.
The information carried in a Feed instance can be converted to a variety of XML formats. The process of converting to and from XML is managed by the SyndicationFeedFormatter class. This class is abstract; concrete implementations are provided for Atom 1.0 and RSS 2.0, Atom10FeedFormatter and Rss20FeedFormatter. To use derived Feed classes, use either Atom10FeedFormatter or Rss20FeedFormatter as they allow you to specify a derived Feed class. To use derived item classes use either Atom10ItemFormatter or Rss20ItemFormatter as they allow you to specify a derived item class Third parties can derive their own implementation of SyndicationFeedFormatter to support different syndication formats.
Extensibility
- A key feature of syndication protocols is extensibility. Both Atom 1.0 and RSS 2.0 allow you to add attributes and elements to syndication feeds that are not defined in the specifications. The WCF syndication programming model provides two ways of working with custom attributes and extensions: deriving a new class and loosely-typed access. For more information, see Syndication Extensibility.
See Also
Concepts
WCF Syndication Overview
How the WCF Syndication Object Model Maps to Atom and RSS