title: Cross-platform RESTful WCF method, passing and returning byte array
body: <p>So simple in theory, but I have never been a wiz at WCF configuration.  What I am trying to do is this:  I have a WCF method that matches this signature: </p>
  
  <pre><code>[OperationContract]
  [WebInvoke(Method = "POST")]
  Stream PostPackets(Stream rawPackets);
  </code></pre>
  
  <p>All I really care about is getting a byte array from an Android/iPhone/Blackberry/any other type of device, to my wcf service, process the array and then send back a different array of bytes.  For all I care, it could look like:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke(Method = "POST")]
  byte[] PostPackets(byte[] rawPackets);
  </code></pre>
  
  <p>Though all examples I see seem to use Stream.</p>
  
  <p>I have read many different articles and posts with no straight answer on how to do this outside the context of a file transfer (which is not my intention).  Here are the problems I am facing:</p>
  
  <p>1- I assume I need to use webHttpBinding to make this service RESTful.  Is this right?  If so, can you point me to a sample configuration?</p>
  
  <p>2 - (And this is absolutely what I cannot find anywhere!) I need to be sure that this is not going to be a huge pain for the device developers to consume.  Can you show me examples of both Android and iPhone devices consuming a RESTful service AND (very important) how they would send a byte array to my service?</p>
  
  <p>Please forgive my noobiness... WCF configuration is one of those things I don't get to do every day.  Once I get my configuration figured out, I generally move on and never have to touch it until my next project (which could be a very long time).  Please help!</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>My colleague suggested that we use http handlers instead of wcf.  Do we really have to resort to that?<br>
  e.g.: </p>
  
  <pre><code>public void ProcessPackets (HttpContext context) 
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>I am wondering, is there any way to do this without JSON?  Is there any downside/alternative to posting the array as type "text/plain"?</p>