Last week I showed how to use the Telerik OpenAccess WCF Wizard to automatically create a feed in Atom Syndication Format using the WCF REST Starter Kit’s Visual Studio project templates. Based on the feedback we have gotten from the community on the ATOMPub projects, Telerik has refreshed the WCF Wizard (go download it now) to enhance the ATOMPub projects.

Let’s take a step back first. The Atom Syndication Format is for feeds, similar to RSS. So when you run the project that we looked at in my blog last week in default IE 8 (or IE 7) feed view, it would look something like this. This is no different from what my feeds look like from CNN and ESPN, etc.

image

But how did IE decide what to put as the title or the description of each item in the feed? (And since we are just exposing OpenAccess entities as feeds, the real question is which properties (or database fields at the end of the day) did IE choose for you?)

If you go back to IE settings and turn off feed view (which I always recommend when working with Astoria, REST Collection, and ATOMPub services) you can view the raw XML.

image

As shown in raw XML ATOM feed below in lines 3 and 4 you can see that the Company Name and Contact name were randomly placed into those fields (and that is how IE uses that data to display.) Well it was not randomly selected, I just hard coded those two fields in my demo. For applications these two fields are usually ignored. But it would be nice to have them set to something useful.

 1: <entry>
 2:  <id>ALFKI</id> 
 3:  <title type="text">Alfreds
Futterkiste</title> 
 4:  <summary type="text">Maria
Anders</summary> 
 5:  <updated>2009-09-14T08:16:30Z</updated> 
 6:  
 7:  <category term="customers" /> 
 8: - <content type="text/xml">
 9: 
 10:  <Address>Obere
Str. 57</Address> 
 11:  <City>Berlin</City> 
 12:  <CompanyName>Alfreds
Futterkiste</CompanyName> 
 13:  <ContactName>Maria
Anders</ContactName> 
 14:  <ContactTitle>Sales
Representative</ContactTitle> 
 15:  <Country>Germany</Country> 
 16:  <CustomerID>ALFKI</CustomerID> 
 17:  <Fax>030-0076545</Fax> 
 18:  <Phone>030-0074321</Phone> 
 19:  <PostalCode>12209</PostalCode> 
 20:  <Region i:nil="true" /> 
 21:  </Customer>
 22:  </content>
 23:  </entry>

 

The latest version of the WCF Wizard will now give you a dialog, so you don’t have to alter the code at all. As you can see from the screen shot below, the wizard now gives us a drop down so we can choose which property to expose in feed view as the title and description. So just to be different, I will choose the company name as the title and the Address as the description.

image

 

When we look at the raw ATOMPub XML you will see Company Name and Address in lines 3 and 4.

 1: <entry>
 2:  <id>ALFKI</id> 
 3:  <title type="text">Alfreds
Futterkiste</title> 
 4:  <summary type="text">Obere
Str. 57</summary> 
 5:  <updated>2009-09-14T08:47:12Z</updated> 
 6:  
 7:  <category term="customers" /> 
 8: - <content type="text/xml">
 9: 
 10:  <Address>Obere
Str. 57</Address> 
 11:  <City>Berlin</City> 
 12:  <CompanyName>Alfreds
Futterkiste</CompanyName> 
 13:  <ContactName>Maria
Anders</ContactName> 
 14:  <ContactTitle>Sales
Representative</ContactTitle> 
 15:  <Country>Germany</Country> 
 16:  <CustomerID>ALFKI</CustomerID> 
 17:  <Fax>030-0076545</Fax> 
 18:  <Phone>030-0074321</Phone> 
 19:  <PostalCode>12209</PostalCode> 
 20:  <Region i:nil="true" /> 
 21:  </Customer>
 22:  </content>
 23:  </entry>

 

If you view the service in feed view in IE, you will now see the Company Name and Address as the title and description.

image

Of course this did not effect our Silverlight front end since the application just ignored those fields. Those fields are available to the application, but we did not use them (we only used two fields (company name and contact name from the main XML tree.)

image


About the Author

Steve Forte

 sits on the board of several start-ups including Triton Works. Stephen is also the Microsoft Regional Director for the NY Metro region and speaks regularly at industry conferences around the world. He has written several books on application and database development including Programming SQL Server 2008 (MS Press).

Comments

Comments are disabled in preview mode.