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?