开发者

Why does my WCF web service end the response when the output data is fairly large?

开发者 https://www.devze.com 2022-12-20 03:40 出处:网络
I\'ve set up a WCF web service to be called from my web site. It\'s working great, but if I request a large amount of data (not sure on the size, but it\'s easily 3-4 times larger than the \"standard\

I've set up a WCF web service to be called from my web site. It's working great, but if I request a large amount of data (not sure on the size, but it's easily 3-4 times larger than the "standard" data I'm returning), Cassini (Visual Studio Web Server) just closes the response without sending anything-- no error or anything. Nothing in event log. Just nada.

I'm a newbie to WCF, but I know there must be some configuration option I'm missing here (like a message/response max size/limit) that solves my problem. Here's what my web.config section looks like:

<system.serviceModel>   
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />   
   <behaviors>
   <endpointBehaviors>
    <behavior name="securetmhAspNetAjaxBehavior">
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
   <serviceBehaviors>
    <behavior name="tmhsecureBehavior">
     <serviceM开发者_运维知识库etadata 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.


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

You can obviously change that - there's a gazillion of entries to tweak. See this sample config here:

  <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 the webHttpBinding, and you can tweak all those various settings - I set them all to 256K (instead of 64K).

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消