views:

289

answers:

1

My WCF Service has an OperationContract that accepts, as a parameter, an array of objects. This can potentially be quite large. After looking for fixes for Bad Request: 400, I found the real reason: the maximum message size.

I know this question has been asked before in MANY places. I've tried what everyone says: "Increase the sizes in the client and server config files." I have. It still doesn't work.

My Service's web.config:

<system.serviceModel>
    <services>
      <service name="myService">
        <endpoint name="myEndpoint" address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="myBinding"
                  contract="Meisel.WCF.PDFDocs.IPDFDocsService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="myBinding"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:15:00"
                 sendTimeout="00:15:00"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="Buffered"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

My Client's app.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPDFDocsService"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:11:00"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 transferMode="Buffered"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None"
                       proxyCredentialType="None"
                       realm="" />
            <message clientCredentialType="UserName"
                     algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8451/PDFDocsService.svc"
                behaviorConfiguration="MoreItemsInObjectGraph"
                binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IPDFDocsService"
                contract="PDFDocsService.IPDFDocsService"
                name="BasicHttpBinding_IPDFDocsService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MoreItemsInObjectGraph">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

What can I possibly be missing or doing wrong? It's as though the service is ignoring what I typed in the maxReceivedBufferSize.

Thanks in advance, Kyle

UPDATE

Here are two other StackOverflow questions where they never received an answer, either:

http://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with

http://stackoverflow.com/questions/2569715/wcf-maxreceivedmessagesize-property-not-taking

+2  A: 

In the service config file, the "name" attribute is missing from the element

<behaviors>
  <serviceBehaviors>
    <behavior name="StackOverflow">

and there should be a reference to this name in the service element:

<system.serviceModel>
    <services>
        <service behaviorConfiguration="StackOverflow" name="myService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding"

In general, it's a good idea to validate, if not always edit, your WCF config files using the "WCF Service Configuration Editor", which is invoked from the Visual Studio "Tools" menu item.

Also there is no endpoint behavior defined for the service. I don't know if this matters.

Simon Chadwick
Would you believe me if I told you that when I add a name to my behavior, the WCFTestClient gives me the error: "Error: Cannot obtain Metadata. Metadata contains a reference that cannot be resolved. Content Type application/soap+xml; charset=utf-8 was not supported by service. The client and service bindings may be mismatched. The remote server returned an error: (415) Unsupported Media Type.HTTP GET. The HTML document does not contain Web service discovery information." This is why I didn't include a name for my behavior.
DaleyKD
I'm still not sure what the true solution was to this issue, but I was able to get my ORIGINAL problem resolved, making this issue moot. FWIW, it seems as though I was able to get rid of the above error by making SURE my service used behaviorConfiguration. Thanks!
DaleyKD