title: WCF REST Proxy using ChannelFactory
body: <p>I'm trying to create a proxy WCF service over a WCF service using ChannelFactory.</p>
  
  <p>I have defined the following interface for the WCF service to call. It has a generic GetResource method that writes directly into HttpContext the response byte[] and sets it's content type based on the type of the resource.</p>
  
  <pre><code>[ServiceContract]
  public interface ITest
  {
    [OperationContract]
    [WebInvoke(Method = "GET", UriTemplate = "getResource/?resourceKey={resourceKey}")]
    void GetResource(string resourceKey);
  }
  </code></pre>
  
  <p>Proxy implementation for GetResource:</p>
  
  <pre><code>public void GetResource(string resourceKey)
  {
     var factory = new ChannelFactory&lt;ITest&gt;(GetCustomBinding(), new   EndpointAddress('https://test.com/mytest.svc'));
     channel.Endpoint.Behaviors.Add(new WebHttpBehavior());
     var channel = factory.CreateChannel();
    using (var scope = new OperationContextScope((IContextChannel)channel))
    {
      channel.GetResource(resourceKey);
    }
  
  }
  
  
  
  private static Binding GetCustomBinding()
          {
              var binding = new WebHttpBinding(WebHttpSecurityMode.Transport)
              {
                  MaxReceivedMessageSize = 20000000,
                  MaxBufferSize = 20000000,
                  MaxBufferPoolSize = 20000000,
                  CloseTimeout = TimeSpan.FromMinutes(1)
              };
  
              binding.ContentTypeMapper = new JsonMapper();
  
              return binding;
  
          }
  
  private class JsonMapper : WebContentTypeMapper
      {
          public override WebContentFormat GetMessageFormatForContentType(string contentType)
          {
  
                  return WebContentFormat.Json;
  
          }
      }
  </code></pre>
  
  <p>The problem that I have is that when I'm calling the proxy at this endpoint, proxy.svc/GetResource?resourceKey="text.css" it returns the right content type but no actual content, ContentLength=0.</p>
  
  <p>How should I handle Response Body forwarding? How do I read the response body? I tried using WebOperationContext.Current.IncomingResponse but it doesn't give me the response body as well.</p>