简体   繁体   中英

Send and receive large data with WCF

I've implemented a web services that saves and loads text data and image (byte array) into a SQL Server. For to send data, I'm modified the web.config because i received an error for data too big!!!

This is the modify of my web.config:

  <services>
            <service name="myWs_service.Service1">
                <endpoint binding="basicHttpBinding" bindingConfiguration="BasicHttp_LargeObject" contract="myWs_service.Ib2bService" />
            </service>
        </services>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttp_LargeObject" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None"/>
                </binding>
                </basicHttpBinding>
        </bindings>

...and also this:

<httpRuntime targetFramework="4.5"  maxRequestLength="409600" executionTimeout="900"/>

So now I can send all desidered data to the web service, but when I try to retrieve data, I get an error on the MaxReceivedMessageSize configuration!?!?!

Why I can send from client to server and I can't receive from server to client with this configuration?

I will appreciate all suggestions....

EDIT

For greater clarity: The real client app is a Windows App Store app than actually works good when I need to post data. For now I'm testing the app with the console for debug mode: 在此处输入图片说明

and the error message (sorry is in italian) that I retrieve is:

È stata superata la quota massima delle dimensioni per i messaggi in ingresso (65536). Per aumentare la quota, utilizzare la proprietà MaxReceivedMessageSize nell'elemento associazione appropriato.

Server stack trace: 
   in System.ServiceModel.Channels.MessageEncoder.BufferMessageStream(Stream stream, BufferManager bufferManager, Int32 maxBufferSize)
   in System.ServiceModel.Channels.MessageEncoder.ReadMessage(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType)
   in System.ServiceModel.Channels.HttpInput.ReadChunkedBufferedMessage(Stream inputStream)
   in System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
   in System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   in System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   in System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   in System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   in System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   in System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   in System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   in System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   in Ib2bService.listAziende()
   in Ib2bServiceClient.listAziende()

Inner Exception:
È stata superata la quota massima delle dimensioni per i messaggi in ingresso (65536). Per aumentare la quota, utilizzare la proprietà MaxReceivedMessageSize nell'elemento associazione appropriato.

Adjust your binding on the client and server side.

Below is one I found for named-pipes. maxReceivedMessageSize and also see this question:

maxReceivedMessageSize and maxBufferSize in app.config

Client example:

  <netNamedPipeBinding>
    <binding name="NamedPipeBindingName1"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="9000000"
                 maxConnections="10"
                 maxReceivedMessageSize="9000000"
                 receiveTimeout="00:30:00"
                 transactionFlow="false">
      <security mode="Transport">
      </security>
    </binding>
  </netNamedPipeBinding>

Server side (roughly the same thing)

  <netNamedPipeBinding>
    <binding name="NamedPipeBindingName1"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="9000000"
                 maxConnections="500"
                 maxReceivedMessageSize="9000000"
                 receiveTimeout="00:20:00"
                 transactionFlow="false">
      <security mode="Transport">
      </security>
    </binding>
  </netNamedPipeBinding>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM