Why does my WCF web service end up responding when the output is large enough?

I installed a WCF web service to call from my website. It works fine, but if I request a large amount of data (not sure about the size, but it is easily 3-4 times larger than the "standard" data that I return), Cassini (Visual Studio Web Server) just closes the answer, doesn’t sending anything - no error or anything else. Nothing in the event log. Just nada.

I am new to WCF, but I know that there must be some kind of configuration parameter that is missing here (e.g. maximum message / response size / limit) that solves my problem. This is what my web.config section looks like:

<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <behaviors> <endpointBehaviors> <behavior name="securetmhAspNetAjaxBehavior"> <enableWebScript /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="tmhsecureBehavior"> <serviceMetadata httpGetEnabled="false" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service name="securetmh"> <endpoint address="" behaviorConfiguration="securetmhAspNetAjaxBehavior" binding="webHttpBinding" contract="securetmh" /> </service> </services> </system.serviceModel> 

Any help would be appreciated.

+4
source share
1 answer

For security reasons, WCF by default limits the data returned by a service call to 64 K.

You can obviously change this - there are a gazillion entries for customization. See here for an example configuration:

  <system.serviceModel> <bindings> <webHttpBinding> <binding name="customWebHttp" maxBufferPoolSize="256000" maxReceivedMessageSize="256000" maxBufferSize="256000"> <readerQuotas maxArrayLength="256000" maxStringContentLength="256000"/> </binding> </webHttpBinding> </bindings> <services> <service name="YourService"> <endpoint name="test" address="....." binding="webHttpBinding" bindingConfiguration="customWebHttp" contract="IYourService" /> </service> </services> </system.serviceModel> 

You need to define a custom binding configuration based on webHttpBinding , and you can configure all these different settings - I set them all to 256K (instead of 64K).

Hope this helps!

+5
source

Source: https://habr.com/ru/post/1301476/


All Articles