2015-07-02 140 views
0

我已经实现了将文本数据和图像(字节数组)保存并加载到SQL Server中的Web服务。 为了发送数据,我修改了web.config,因为我收到数据太大的错误!用WCF发送和接收大数据

这是我的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> 

...而且这样的:

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

所以现在我都可以desidered数据发送到Web服务,但是当我尝试检索数据,我在MaxReceivedMessageSize配置上遇到错误!!!?!

为什么我可以从客户端发送到服务器,并且我无法通过此配置从服务器接收客户端?

我会感谢所有的建议....

编辑

为了更清楚: 真正的客户端应用程序是Windows App Store应用比实际工作很好,当我需要发布的数据。 现在我与控制台调试模式下测试应用程序: enter image description here

和错误消息(对不起的就是在意大利),我检索是:

È 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. 
+0

你如何试图检索数据? –

+0

实际的错误信息是什么?错误与wcf或客户端上的问题有关?你也检查客户端上的设置吗?请注意,限制也适用于客户;您必须配置客户端以允许传输所需数量的数据。 – Paolo

回答

0

调整客户端上你的绑定和服务器端。

下面是我找到的命名管道。 maxReceivedMessageSize也看到了这个问题:

maxReceivedMessageSize and maxBufferSize in app.config

客户例如:

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

服务器端(大致相同的事情)

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