1

From my Silverlight 4 project, I have a call to a WCF service which is accessed via a wrapper service. This is just a WCF Service Application with a Service Reference to my other WCF. I am getting the following exception:

"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.".

While debugging I see:

ProtocolException was unhandled by user code -- The remote server returned an unexpected response: (400) Bad Request.

In Silverlight, a 404 response code may be reported even when the service sends a different error code.

I am using Silverlight 4 & .NET 4.0.

I can change maxBufferSize & maxReceivedMessageSize to 524288 in the WCF Test Client to see my expected results.

How can I change these values so that they are actually used instead of the WCF default settings?

Wrapper Service web.config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMyService" closeTimeout="00:02:00"
          openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="524288" maxBufferPoolSize="524288" maxReceivedMessageSize="524288"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="524288" maxStringContentLength="524288" maxArrayLength="524288"
            maxBytesPerRead="524288" maxNameTableCharCount="524288" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://internal:51505/SvcApp/MySvc_MyService.svc"
          binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IMyService"
          contract="WCFServiceRef.IMyService"
          name="BasicHttpBinding_IMyService" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

Web project web.config:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpsBinding_IMyWrapperService" maxBufferSize="524288"
       maxReceivedMessageSize="524288">
        <security mode="Transport" />
      </binding>
      <binding name="BasicHttpBinding_IMyWrapperService" closeTimeout="00:02:00"
       openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
       maxBufferSize="524288" maxBufferPoolSize="524288" maxReceivedMessageSize="524288"
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
       useDefaultWebProxy="true">
        <readerQuotas maxDepth="524288" maxStringContentLength="524288" maxArrayLength="524288"
         maxBytesPerRead="524288" maxNameTableCharCount="524288" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None"
           realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://internal/mysvc/MyWrapperService.svc"
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IMyWrapperService"
              contract="WrapperServiceServiceRef.IMyWrapperService"
              name="BasicHttpBinding_IMyWrapperService" />
  </client>
</system.serviceModel>

I have seen suggestions to name my serviceBehavior and add maxItemsInObjectGraph.

I tried adding "LargeEndpointBehavior", but this did not seem to do anything.

<client>
  <endpoint address="http://internal:51505/SvcApp/MySvc_MyService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IMyService"
      contract="WCFServiceRef.IMyService"
      name="BasicHttpBinding_IMyService"
      behaviorConfiguration="LargeEndpointBehavior" />
</client>

<behaviors>
  <serviceBehaviors>
    <behavior name="LargeEndpointBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Do I just need to fix my service wrapper web.config?

The service that I'm calling via the wrapper, the ServiceReferences.ClientConfig in my Silverlight project & the web application which hosts my xap file have all values maxed out.

Any suggestions?

Chris
  • 8,527
  • 10
  • 34
  • 51
irblack
  • 11
  • 1
  • 2
  • I don't see any explicitly defined service endpoints - if you don't have one in one of the config files, than any changes you make to the binding won't take effect unless you make that configuration the default (by removing the `name` attribute) or create an explicit endpoint and assigning your binding to it. See this question and answer for what appears to be a similiar question: http://stackoverflow.com/q/18849341/745969 – Tim Sep 17 '13 at 21:44

0 Answers0