<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>freemind blogs &#187; rest</title>
	<atom:link href="http://blogs.freemind.net/index.php/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.freemind.net</link>
	<description></description>
	<lastBuildDate>Thu, 19 Nov 2009 04:49:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using WCF REST Starter Kit to Access Constant Contact API</title>
		<link>http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/</link>
		<comments>http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/#comments</comments>
		<pubDate>Fri, 01 May 2009 19:30:37 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[atompub]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[wcf]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=57</guid>
		<description><![CDATA[Problem: Allow customers to sign up for email newsletters and synchronize those accounts with Constant Contact. Constant Contact is a company that provides Email Marketing services. You can use their editor to create nice looking emails and then configure a list of contacts. Constant Contact handles all the email sending, bounces, and unsubscribe activities. They [...]]]></description>
			<content:encoded><![CDATA[<p>Problem: Allow customers to sign up for email newsletters and synchronize those accounts with Constant Contact.</p>
<p><a title="Constant Contact" href="http://constantcontact.com" target="_blank">Constant Contact</a> is a company that provides Email Marketing services. You can use their editor to create nice looking emails and then configure a list of contacts. Constant Contact handles all the email sending, bounces, and unsubscribe activities. They also provide excellent reporting features to track how many people actually view your emails or click on the contained links.</p>
<p>The nice folks at Constant Contact provide a set of <a href="http://developer.constantcontact.com/doc" target="_blank">web services </a>for accessing account data. These interfaces are implemented as REST services utilizing the Atom Publication Protocol (AtomPub) and Atom Syndication Format. At first it might seem odd to be accessing data objects via a <em>blogging</em> protocol but it actually works quite naturally. So well that Google&#8217;s GData and Microsoft&#8217;s ADO.NET Data Services also support this technique.</p>
<p>Writing all the HTTP, Auth, and XML parsing code can be a real drag. Luckily Microsoft is releasing a <a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644" target="_blank">WCF REST Starter Kit</a>. From the CodePlex summary:</p>
<blockquote><p><span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel">The WCF REST Starter Kit is a set of .Net Framework classes and Visual Studio features and templates that enable users to create and access REST-style Windows Communication Foundation (WCF) services. These services are based on the WCF web programming model available in .Net 3.5 SP1. The starter kit also contains the full source code for all features, detailed code samples, and unit tests.</span></p></blockquote>
<p>This starter kit makes accessing the Constant Contact API quite simple. Call GetEntry or GetFeed with a URI and get back a SyndicationItem or SyndicationFeed (collection of items). Similar methods exist for adding and updating data (AddEntry and UpdateEntry).</p>
<p>The following is one method from my ContactListProvider class:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> ContactList GetContactList<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;AtomPubClient client <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> AtomPubClient<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;client<span style="color: #008000;">.</span><span style="color: #0000FF;">TransportSettings</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Credentials</span> <span style="color: #008000;">=</span> GetLoginCredentials<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// Place in a try block to ensure that any errors are caught</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">try</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; SyndicationItem item <span style="color: #008000;">=</span> client<span style="color: #008000;">.</span><span style="color: #0000FF;">GetEntry</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Uri<span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; ContactList list <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ContactList<span style="color: #008000;">&#40;</span>item<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span> <span style="color: #0600FF; font-weight: bold;">as</span> XmlSyndicationContent<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> list<span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>WebException ex<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; _log<span style="color: #008000;">.</span><span style="color: #0000FF;">Error</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;WebException: &quot;</span> <span style="color: #008000;">+</span> ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Status</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span>, ex<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception ex<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Get the exception type</span><br />
&nbsp; &nbsp; &nbsp; _log<span style="color: #008000;">.</span><span style="color: #0000FF;">Error</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Exception: &quot;</span> <span style="color: #008000;">+</span> ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span>, ex<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Contact me via comments if you want a copy of all the providers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
