0
votes

I'm trying to transfer a large data object from a WinForms client via WCF.

When the client tries to get the object from the server, the transfer succeeds; but when the client tries to send the object to the server, I get an error!!

The error is:

at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ClientReliableChannelBinder1.RequestClientReliableChannelBinder1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) at System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(Message message, TimeSpan timeout) at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

I try to add the behavior attribute DataContractSerializer and set it to max value. The transferring works only one way - from the server to the client! On the other side - from the client to the server it doesn't work!

Thank you for your help.

2
Can you include the ErrorMessage for the exception?regex
Can you post the configuration you have on your client and server?Rajesh

2 Answers

2
votes

Try adding the following parameters to your web.config file (adapt the value for your case):

<behaviors>
    <serviceBehaviors>
        <behavior name="">
            <dataContractSerializer maxItemsInObjectGraph="6553600"/>
        </behavior>
    </serviceBehaviors>
</behaviors>

...    

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="512000000" />
        </requestFiltering>
    </security>
</system.webServer>
1
votes

There are several settings that control the max size of a message

  • MaxBufferSize
  • MaxReceivedMessageSize
  • MaxStringContentLength

See: http://geekswithblogs.net/niemguy/archive/2007/12/11/wcf-maxstringcontentlength-maxbuffersize-and-maxreceivedmessagesize.aspx