title: ASP Rest Services with Stream
body: <p>I am trying to building a REST Service with Stream input which I eventually want to save in a file on the server. My problem is that when I run the service I get 'EndPoint not found'</p>
  
  <p>I am using VS 2010 with .NET 4.0</p>
  
  <p>My Service Model is as under</p>
  
  <p></p>
  
  <pre><code>&lt;services&gt;
    &lt;service name="WCFService1.TestService" behaviorConfiguration="ServiceBehaviour"&gt;
      &lt;endpoint address=""
                binding="webHttpBinding"
                contract="WCFService1.ITestService"
                behaviorConfiguration="web" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="ServiceBehaviour"&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="web"&gt;
        &lt;webHttp/&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;      
  &lt;/behaviors&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code is very simple at this stage.
  Service Code</p>
  
  <pre><code>namespace WCFService1
  {
  // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
  [ServiceContract]
  
    public interface ITestService
    {
      [OperationContract]
      [WebInvoke(Method = "POST", UriTemplate = "UploadFile/{fileName}", BodyStyle = WebMessageBodyStyle.Bare)]
      Stream UploadFile(string fileName, Stream fileContents);
    }
  }
  </code></pre>
  
  <p>Function implementation</p>
  
  <pre><code>    public Stream UploadFile(string fileName, Stream fileContents)
      {
          //save file
          var sr = new StreamReader(fileContents);
          string text = sr.ReadToEnd();
          return new System.IO.MemoryStream(Encoding.UTF8.GetBytes("Hello World! " + text + fileName));
      }
  </code></pre>
  
  <p>svc file</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="WCFService1.TestService"   CodeBehind="TestService.svc.cs"   Factory="System.ServiceModel.Activation.WebServiceHostFactory"%&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>