<?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>Southworks Blog &#187; Edgardo Rossetto</title> <atom:link href="http://southworks.com/blog/author/erossetto/feed/" rel="self" type="application/rss+xml" /><link>http://southworks.com/blog</link> <description>Southworks Blog</description> <lastBuildDate>Mon, 11 Jul 2016 23:03:36 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=4.1.12</generator> <item><title>Raw HTTP POST with WCF</title><link>http://southworks.com/blog/2007/09/03/raw-http-post-with-wcf/</link> <comments>http://southworks.com/blog/2007/09/03/raw-http-post-with-wcf/#comments</comments> <pubDate>Mon, 03 Sep 2007 14:40:18 +0000</pubDate> <dc:creator><![CDATA[Edgardo Rossetto]]></dc:creator> <category><![CDATA[Uncategorized]]></category><guid
isPermaLink="false">http://blogs.southworks.net/erossetto/2007/09/03/raw-http-post-with-wcf/</guid> <description><![CDATA[(From an interesting thread in the MSDN forums&#8230;) WCF does not support raw HTTP requests with the content-type &#8216;application/x-www-form-urlencoded&#8217; (which is the content-type the browser sends when you hit &#8216;submit&#8217;...]]></description> <content:encoded><![CDATA[<p><a
href="http://blogs.southworks.net/erossetto/files/2008/06/rawhttppostwcf.zip"></a>(From an interesting thread in the <a
href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2009880&amp;SiteID=1">MSDN forums&#8230;</a>)</p><p>WCF does not support raw HTTP requests with the content-type <em>&#8216;application/x-www-form-urlencoded&#8217;</em> (which is the content-type the browser sends when you hit &#8216;submit&#8217; in a &lt;form&gt; element) out of the box unless you treat the request body as a <a
href="http://msdn2.microsoft.com/en-us/library/system.io.stream.aspx">Stream</a>.</p><p>This makes sense if you consider that the same principle applies when returning data, as you can see <a
href="http://www.cloudsamples.net/ContextBar/SrcViewer/?name=PictureServices&amp;f=PictureSyndicationPictureService.cs">here</a> in the Picture Services sample, both the GetDocumentation() and GetPicture() operations return a Stream with data; all you need to do is set the content-type properly and you&#8217;re good to go.</p><p>I&#8217;ve created a little sample that shows how to POST data from a HTML form and parse it in WCF with a little help from the System.Web namespace.</p><p>Consider the following service contract:</p><div
class="code"><div
class="codePadder"><div
style="font-size: 10pt;color: black;font-family: consolas,courier new"><pre style="margin: 0px">[<span style="color: #2b91af">ServiceContract</span>]</pre><pre style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">interface</span> <span style="color: #2b91af">ISampleService</span></pre><pre style="margin: 0px">{</pre><pre style="margin: 0px">    [<span style="color: #2b91af">OperationContract</span>]</pre><pre style="margin: 0px">    [<span style="color: #2b91af">WebInvoke</span>(UriTemplate = <span style="color: #a31515">"invoke"</span>)]</pre><pre style="margin: 0px">    <span style="color: blue">void</span> DoWork(<span style="color: #2b91af">Stream</span> input);</pre><pre style="margin: 0px">}</pre></div></div></div><p>Sample HTML form:</p><p><a
href="http://southworks.com/blog/wp-content/uploads/sites/81/2008/06/ie-form.png"><img
src="http://southworks.com/blog/wp-content/uploads/sites/81/2008/06/ie-form-thumb.png" border="0" alt="ie_form" width="413" height="275" /></a></p><p>HTML source:</p><div
class="code"><div
class="codePadder"><div
style="font-size: 10pt;color: black;font-family: consolas,courier new"><pre style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">form</span><span style="color: blue"> </span><span style="color: red">method</span><span style="color: blue">=</span>"<span style="color: blue">post</span>"<span style="color: blue"> </span><span style="color: red">action</span><span style="color: blue">=</span>"<span style="color: blue">Service.svc/invoke</span>"<span style="color: blue">&gt;</span></pre><pre style="margin: 0px"><span style="color: blue">    &lt;</span><span style="color: #a31515">label</span><span style="color: blue"> </span><span style="color: red">for</span><span style="color: blue">=</span>"<span style="color: blue">firstName</span>"<span style="color: blue">&gt;</span>First Name<span style="color: blue">&lt;/</span><span style="color: #a31515">label</span><span style="color: blue">&gt;</span>: <span style="color: blue">&lt;</span><span style="color: #a31515">input</span><span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">text</span>"<span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">firstName</span>"<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>""<span style="color: blue"> /&gt;</span></pre><pre style="margin: 0px"><span style="color: blue">    &lt;</span><span style="color: #a31515">br</span><span style="color: blue"> /&gt;&lt;</span><span style="color: #a31515">br</span><span style="color: blue"> /&gt;</span></pre><pre style="margin: 0px"><span style="color: blue">    &lt;</span><span style="color: #a31515">label</span><span style="color: blue"> </span><span style="color: red">for</span><span style="color: blue">=</span>"<span style="color: blue">lastName</span>"<span style="color: blue">&gt;</span>Last Name<span style="color: blue">&lt;/</span><span style="color: #a31515">label</span><span style="color: blue">&gt;</span>: <span style="color: blue">&lt;</span><span style="color: #a31515">input</span><span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">text</span>"<span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">lastName</span>"<span style="color: blue"> </span><span style="color: red">value</span><span style="color: blue">=</span>""<span style="color: blue"> /&gt;</span></pre><pre style="margin: 0px"><span style="color: blue">    &lt;</span><span style="color: #a31515">p</span><span style="color: blue">&gt;&lt;</span><span style="color: #a31515">input</span><span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">submit</span>"<span style="color: blue"> /&gt;&lt;/</span><span style="color: #a31515">p</span><span style="color: blue">&gt;</span></pre><pre style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">form</span><span style="color: blue">&gt;</span></pre></div></div></div><p>Here&#8217;s how you read the input Stream:</p><div
class="code"><div
class="codePadder"><div
style="font-size: 10pt;color: black;font-family: consolas,courier new"><pre style="margin: 0px"><span style="color: blue">public</span> <span style="color: blue">void</span> DoWork(<span style="color: #2b91af">Stream</span> input)</pre><pre style="margin: 0px">{</pre><pre style="margin: 0px">    <span style="color: #2b91af">StreamReader</span> sr = <span style="color: blue">new</span> <span style="color: #2b91af">StreamReader</span>(input);</pre><pre style="margin: 0px">    <span style="color: blue">string</span> s = sr.ReadToEnd();</pre><pre style="margin: 0px">    sr.Dispose();</pre><pre style="margin: 0px">    <span style="color: #2b91af">NameValueCollection</span> qs = <span style="color: #2b91af">HttpUtility</span>.ParseQueryString(s);</pre><pre style="margin: 0px">    <span style="color: blue">string</span> firstName = qs[<span style="color: #a31515">"firstName"</span>];</pre><pre style="margin: 0px">    <span style="color: blue">string</span> lastName = qs[<span style="color: #a31515">"lastName"</span>];</pre><pre style="margin: 0px">    <span style="color: green">// Do work here</span></pre><pre style="margin: 0px">}</pre></div></div></div><p><a
href="http://blogs.southworks.net/erossetto/files/2008/06/rawhttppostwcf.zip">I&#8217;ve attached the full sample</a>.</p><p>Hope this helps</p> ]]></content:encoded> <wfw:commentRss>http://southworks.com/blog/2007/09/03/raw-http-post-with-wcf/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Picture Services Sample Released</title><link>http://southworks.com/blog/2007/08/30/picture-services-sample-released/</link> <comments>http://southworks.com/blog/2007/08/30/picture-services-sample-released/#comments</comments> <pubDate>Thu, 30 Aug 2007 15:55:28 +0000</pubDate> <dc:creator><![CDATA[Edgardo Rossetto]]></dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Orcas]]></category><guid
isPermaLink="false">http://blogs.southworks.net/erossetto/2007/08/30/picture-services-sample-released/</guid> <description><![CDATA[As Justin announced here, the Picture Services sample was released a few days ago. It&#8217;s cool when a project you&#8217;re involved in (in my case helping the DPE folks) sees...]]></description> <content:encoded><![CDATA[<p>As Justin announced <a
href="http://blogs.msdn.com/justinjsmith/archive/2007/08/20/check-out-picture-services.aspx">here</a>, the Picture Services sample was released a few days ago. It&#8217;s cool when a project you&#8217;re involved in (in my case helping the DPE folks) sees the light. <img
src="http://southworks.com/blog/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p><p>The sample centers around the new WCF 3.5 Syndication API, and shows a variety of cool technologies and scenarios (more info on the Picture Services <a
href="http://www.cloudsamples.net/PictureServices/">homepage</a>), here&#8217;s a list of my favorite features shown in the sample that will hopefully catch your attention:</p><ol><li>How easy is to load and work with any feed on the web (ATOM or RSS) with the new Syndication API</li><li>How to extend feeds with custom extensions, the sample shows how to add <a
href="http://blogs.msdn.com/rssteam/articles/SimpleListExtensionsExplained.aspx">SLE</a> (Simple List Extensions) to a RSS feed</li><li>How to add <a
href="http://en.wikipedia.org/wiki/RSS_Enclosures">enclosures</a></li><li>How to return HTML documents with WCF</li></ol><p><a
href="http://www.netfx3.com/files/folders/sampleservices/entry11931.aspx">Click here to download the bits</a></p><p>Other resources:</p><ol><li><a
href="http://www.cloudsamples.net/ContextBar/SrcViewer/?name=PictureServices">Browse the source code online</a></li><li><a
href="http://www.cloudsamples.net/PictureServices/feed.svc/pictures">Browse the Picture Services feed here</a></li><li><a
href="http://channel9.msdn.com/Showpost.aspx?postid=334896">&quot;A lap around Picture Services&quot;</a>, a screencast by <a
href="http://blogs.msdn.com/justinjsmith/">Justin Smith</a></li></ol> ]]></content:encoded> <wfw:commentRss>http://southworks.com/blog/2007/08/30/picture-services-sample-released/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>