2

I'm new to WCF and am trying to get my head around the labyrinth of configurations the services take. I have a rest service that can return an export of a table, which it larger than the default maxReceivedMessageSize. So I'm been trying to play with the config for this service/endpoint and I'm getting nowhere. Below if the gist of what I'm working on, what am I missing? I simply return List as either JSON or XML and I need to be able to return over the default threshold.

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

<services>
  <!-- defin service -->
  <service behaviorConfiguration="EPRestBehavior" name="EPRestDNS">
    <endpoint address="" 
              bindingConfiguration="ApiExportBinding"
              binding="webHttpBinding" 
              contract="IDNSRestService" />
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="EPRestBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>

  ...

</behaviors>
<bindings>
  <!-- Customizations for REST service -->
  <webHttpBinding>
    <binding name="ApiExportBinding" maxReceivedMessageSize="10485760"
                    maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00"
                    openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
      <readerQuotas maxDepth="32" maxStringContentLength="10485760"
                      maxArrayLength="10485760" maxBytesPerRead="10485760" />
      <security mode="None" />
    </binding>
  </webHttpBinding>
</bindings>

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
  </webHttpEndpoint>
</standardEndpoints>

UPDATE 1 I've removed all of that config and tried something simper with the existing webHttpEndpoint section:

<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="1000000000" />
  </webHttpEndpoint>
</standardEndpoints>

with the same results. HTTP/1.1 502 Connection reset by peer

bryan
  • 1,031
  • 2
  • 17
  • 36

2 Answers2

3

All this is why WCF is horrible. In the end I create a svclog on the server and the actual issue was hitting the limit in the default object graph. I added the new limit I want to the implementation, and that was that. 7+ hours just for a stupid thing like that.

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, MaxItemsInObjectGraph = 2147483646)]
bryan
  • 1,031
  • 2
  • 17
  • 36
2

Does the exception occur on the service or the client side? A common mistake is that you change the values on the server but forget to change also on the client.

Per Kastman
  • 4,466
  • 24
  • 21
  • good point, it's client side. Using Fiddler I see that I get a 502 connection reset error, but no exceptions are thrown on the server or while debugging. It's like I'm missing something that lets the client know "hey, you're about to get a decent chunk of data, hang around for a second to get it all". – bryan Jan 06 '12 at 14:50
  • So you get no exeption thrown? – Per Kastman Jan 06 '12 at 15:18
  • nope, nothing. Just client errors in both Fiddler and the browser. – bryan Jan 06 '12 at 16:31
  • see update for my latest attempt. And yes have anther method for returning a search, and that works fine with a subset of the data, but returning it all fails and I'm not sure what I need to change. – bryan Jan 06 '12 at 16:45