title: WCF Rest service endpoint not getting triggered when passing image over a certain size
body: <p>SUMMARY:  When an image exceeds a certain size, the endpoint on my REST service never triggers.</p>
  
  <p><strong><em>Disclaimer:  I have looked at I think every single post on StackOverflow and google for that matter related to this topic.  Nothing I've tried has worked.</em></strong></p>
  
  <p>I suspect I'm missing something due to sheer ignorance.  I'm relatively new to WCF.  </p>
  
  <p>What I've setup is the following:</p>
  
  <ol>
  <li>REST service that exposes multiple endpoints to support image processing.</li>
  <li>Everything is sent/returned as JSON</li>
  </ol>
  
  <p>Here is a copy of my web.config:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;webHttpBinding&gt;
          &lt;binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00"&gt;
            &lt;readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" /&gt;
            &lt;security mode="None"/&gt;
          &lt;/binding&gt;
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service name="ImgService.Service1"&gt;
          &lt;endpoint 
          name="REST" 
          address="" 
              binding="webHttpBinding" 
          contract="ImgService.IDataService" 
          behaviorConfiguration="restfulBehavior"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="restfulBehavior"&gt;
            &lt;webHttp /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;serviceMetadata httpGetEnabled="True"/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="True"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  
  &lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;&lt;/startup&gt;&lt;/configuration&gt;
  </code></pre>
  
  <p>This is what my endpoint looks like as defined in the service:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke(UriTemplate = "/WarpImage",
      ResponseFormat = WebMessageFormat.Json,
      Method = "POST",
      RequestFormat = WebMessageFormat.Json)]
  ServiceResponse&lt;DataContracts.PROCImgObject&gt; WarpImage(DataContracts.PROCImgObject imgObject);
  </code></pre>
  
  <p>The PROCImgObject is defined as follows:</p>
  
  <pre><code>[DataContract]
  public class PROCImgObject : PROCServiceObject
  {
      [DataMember]
      public System.Drawing.Point leftWaist { get; set; }
  
      [DataMember]
      public System.Drawing.Point rightWaist { get; set; }
  
      [DataMember]
      public System.Drawing.Point leftNavel { get; set; }
  
      [DataMember]
      public System.Drawing.Point rightNavel { get; set; }
  
      [DataMember]
      public System.Drawing.Point leftHips { get; set; }
  
      [DataMember]
      public System.Drawing.Point rightHips { get; set; }
  
      [DataMember]
      public int BodyTypeID { get; set; }
  
      [DataMember]
      public double WaistInInches { get; set; }
  
      [DataMember]
      public String Base64EncodedImageData { get; set; }
  
      public PROCImgObject()
      {
          Service1.writeMessage("Create image called");
      }
  }
  </code></pre>
  
  <p>The bitmap data is base64 encoded and passed to the service as part of a JSON structure.</p>
  
  <p>Now to test the failure I am making a call from an Android application I'm developing to test this with.  In order to test what size the image fails at, I started resizing the image in code.</p>
  
  <p>Here is the Android code snippet to resize the image:</p>
  
  <pre><code>        PROCImgObject imgObj = new PROCImgObject();
          imgObj.BodyTypeID = 4;
          imgObj.WaistInInches = 40;
          Bitmap resized = ImageUtil.getResizedBitmap(mCurrentPicture.TheBitmap, 300, 300);
          int numberOfBytes = resized.getByteCount();
          String base64 = ImageUtil.encodeTobase64(resized);
          imgObj.Base64EncodedImageData = base64;
  
          warpService = new ServicePostWarpImage();
          warpService.execute(imgObj);
          warpService.delegate = SnapImage.this; 
  </code></pre>
  
  <p>When I resize the bitmap to 255,255...the endpoint triggers and works fine.</p>
  
  <p>When I resize the bitmap to 256,256...the endpoint never triggers and the code never fires.  I also don't receive any type of exception...is the service just rejecting the call due to the size of the base64Encoded string in the JSON structure?</p>
  
  <p>I'd really apprecaite any insight/push in the right direction/suggestions on how to make the configuration and code better.</p>
  
  <p>I'm somewhat new to WCF.</p>
  
  <p>Thanks everyone.</p>