<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WCF &amp;quot;Raw&amp;quot; programming model (Web) - receiving arbitrary data</title><link>http://blogs.msdn.com/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx</link><description>The previous post mentioned how to return arbitrary data from WCF services. To receive data, however, there is one extra step, which I'll try to explain here. Like returning arbitrary data, the key for accepting arbitrary (in any format) data is for a</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: WCF "Raw" programming model (Web) - receiving arbitrary data</title><link>http://blogs.msdn.com/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx#8962929</link><pubDate>Wed, 24 Sep 2008 03:45:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8962929</guid><dc:creator>eggshelly</dc:creator><description>&lt;p&gt;Awesome article Carlos - it helped me almost solve my seeming insurmountable wcf file upload problem.&lt;/p&gt;
&lt;p&gt;But of course, I have a problem:&lt;/p&gt;
&lt;p&gt;I've implemented your code from above but I'm trying to use the browser as a client. &amp;nbsp;I used YUI from a simple HTML page to submit a form containing a file upload control. &amp;nbsp;When I upload any kind of file, the web service receives the request but when it saves the file, the end result is surrounded with meta-data:&lt;/p&gt;
&lt;p&gt;-----------------------------1654974419512&lt;/p&gt;
&lt;p&gt;Content-Disposition: form-data; name=&amp;quot;upFile&amp;quot;; filename=&amp;quot;amazon phone number.txt&amp;quot;&lt;/p&gt;
&lt;p&gt;Content-Type: text/plain&lt;/p&gt;
&lt;p&gt;[file content here - perfectly reproduced (if I remove the surrounding junk)]&lt;/p&gt;
&lt;p&gt;-----------------------------1654974419512--&lt;/p&gt;
&lt;p&gt;So there must be some difference between how the POST is coming across from YUI and how it's coming across from the HttpWebRequest class, but I can't figure out what that is. &amp;nbsp;Any ideas?&lt;/p&gt;
&lt;p&gt;My web config is set up like:&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;system.serviceModel&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;behaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;endpointBehaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;behavior name=&amp;quot;TestBehavior&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;webHttp/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/behavior&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/endpointBehaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/behaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;bindings&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;webHttpBinding&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;binding name=&amp;quot;fileUploadCapable&amp;quot; maxReceivedMessageSize=&amp;quot;500000000&amp;quot; transferMode=&amp;quot;Streamed&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/webHttpBinding&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/bindings&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;services&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;service name=&amp;quot;Test&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;endpoint address=&amp;quot;ajax&amp;quot; behaviorConfiguration=&amp;quot;TestBehavior&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;binding=&amp;quot;webHttpBinding&amp;quot; bindingConfiguration=&amp;quot;fileUploadCapable&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;contract=&amp;quot;ITest&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/service&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/services&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;/system.serviceModel&amp;gt;&lt;/p&gt;
&lt;p&gt;And my service has the following interface:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[OperationContract]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[WebInvoke(UriTemplate = &amp;quot;UploadFile?upFile={fileName}&amp;quot;)]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;void UploadFile(string fileName, Stream fileContents);&lt;/p&gt;
&lt;p&gt; and implementation:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void UploadFile(string fileName, Stream fileContents)&lt;/p&gt;
</description></item><item><title>BlogSvc Preview Release 0.2</title><link>http://blogs.msdn.com/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx#9247945</link><pubDate>Mon, 22 Dec 2008 22:49:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9247945</guid><dc:creator>BlogSvc News</dc:creator><description>&lt;p&gt;I've put a new release up on codeplex. This release includes an implementation of Atom…&lt;/p&gt;
</description></item><item><title>re: WCF "Raw" programming model (Web) - receiving arbitrary data</title><link>http://blogs.msdn.com/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx#9858281</link><pubDate>Wed, 05 Aug 2009 21:07:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9858281</guid><dc:creator>jimblust</dc:creator><description>&lt;p&gt;Carlos, this is a great example, and I have it working in a console app. I've managed to modify the example so that the service can be hosted in IIS, but my tests indicate that IIS always waits to receive the entire request before handing it off to WCF for processing. Do you know if there's any way to make IIS hand off the streaming request to the service as soon as the request starts coming in? I've also asked on the WCF msdn forum here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/cfe625b2-1890-471b-a4bd-94373daedd39"&gt;http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/cfe625b2-1890-471b-a4bd-94373daedd39&lt;/a&gt; &lt;/p&gt;
</description></item></channel></rss>