title: WCF REST service not passing POST request body stream when using custom binding
body: <p>Following up from the solution to the previous question I asked <a href="https://stackoverflow.com/questions/12689086/adding-gzip-to-wcf-rest-service-in-c-sharp/12815919">here</a>. It seems I now have a problem where if I use a custom binding in my .NET4 web service, then my methods that implement the web service WebInvoke contracts are no longer getting called when they contain the argument of the request body Stream.</p>
  
  <p>So here's code that runs the webservice as found from the the link above:</p>
  
  <pre><code>webserviceHost = new WebServiceHost(typeof(Service1), new Uri("http://localhost:8080));
  webserviceHost.AddServiceEndpoint(typeof(IService), getBinding(), "webservice").Behaviors.Add(new WebHttpBehavior());
  webserviceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
  webserviceHost.Open();
  </code></pre>
  
  <p>Here's the WebInvoke service contract defined:</p>
  
  <pre><code>[WebInvoke(UriTemplate = "import_data?param={value}", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  WebResult importOrder(string value, Stream httpRequestPostBody);
  </code></pre>
  
  <p>And here's the method implementing the above contract:</p>
  
  <pre><code>public WebResult importOrder(String value, Stream httpRequestPostBody)
  {
      doSomething(value, httpRequestPostBody);
  }
  </code></pre>
  
  <p>So if I try making a HTTP request through Fiddler to the webservice endpoint contract it will return a connection reset HTTP error response. If I remove the Stream httpRequestPostBody argument then it will run the method, but I have no way to get access to the raw JSON data in the request body (I can get the body but its in an XML form). So I can only gather that I'm missing something in my custom binding to ensure that the body stream of the request can be passed. Anybody got any clues?</p>