我知道很久以前就已经问过这个问题,但遗憾的是他们都没有解决我的问题。
我有一个wcf web服务,我可以在其中以字节的形式发送文件。如果文件的大小很大(大约400 KB),则会出现此错误。对于小型文件,这个问题不会出现。以下是我的服务器端点配置
<service behaviorConfiguration="CPServicesBehaviour" name="ConsumerPortalAPI.ReceiveNoteService">
<endpoint address="" binding="customBinding" bindingConfiguration="CustomBinding_IReceiveNoteService" contract="ConsumerPortalAPI.IReceiveNoteService" />
</service>
&#13;
绑定配置是,
<binding name="CustomBinding_IReceiveNoteService" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation" requireDerivedKeys="false" includeTimestamp="false" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
canRenewSecurityContextToken="true">
<secureConversationBootstrap defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</secureConversationBootstrap>
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<binaryMessageEncoding>
<readerQuotas maxDepth="32767" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="32767" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpsTransport />
</binding>
&#13;
默认绑定是,
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation" requireDerivedKeys="false" includeTimestamp="false" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
canRenewSecurityContextToken="true">
<secureConversationBootstrap defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</secureConversationBootstrap>
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<binaryMessageEncoding>
<readerQuotas maxDepth="32767" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="32767" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpsTransport />
</binding>
&#13;
在我的测试客户端,配置是,
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IReceiveNoteService" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation" requireDerivedKeys="false" includeTimestamp="false" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
canRenewSecurityContextToken="true">
<secureConversationBootstrap defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</secureConversationBootstrap>
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://cnsportal3.lineartitle.com/cnsAPI/v4/ReceiveNoteService.svc" binding="customBinding" bindingConfiguration="CustomBinding_IReceiveNoteService" contract="CPAction.IReceiveNoteService" name="CustomBinding_IReceiveNoteService" />
</client>
</system.serviceModel>
</configuration>
&#13;
我尝试将我网站的uploadReadAheadSize增加到10485759。 我也尝试将我网站的maxAllowedContentLength增加到3000000000。
我通过system.diagnostics检查了服务器上的Web跟踪。以下是跟踪中记录的Xml消息,
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>524326</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2015-01-21T11:01:33.3751197Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{90d52ffb-d886-4164-9d84-e74c04eb79b4}" />
<Execution ProcessName="w3wp" ProcessID="5916" ThreadID="16" />
<Channel />
<Computer>RES-DEV-WEB</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.GetServiceElement.aspx</TraceIdentifier>
<Description>Get ServiceElement.</Description>
<AppDomain>/LM/W3SVC/5/ROOT/cnsAPI/v4-2-130663116927511157</AppDomain>
<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/ServiceConfigurationTraceRecord">
<FoundServiceElement>True</FoundServiceElement>
<ConfigurationFileSource>C:\inetpub\wwwroot\cnsportal3.lineartitle.com\ConsumerPortalAPI\v4\web.config</ConfigurationFileSource>
<ConfigurationFileLineNumber>133</ConfigurationFileLineNumber>
<ServiceConfigurationInformation>
<ServiceName>ConsumerPortalAPI.ReceiveNoteService</ServiceName>
<BehaviorConfiguration>CPServicesBehaviour</BehaviorConfiguration>
<Host>
<Timeouts>
<OpenTimeout>00:01:00</OpenTimeout>
<CloseTimeout>00:00:10</CloseTimeout>
</Timeouts>
</Host>
<Endpoints>
<Endpoint>
<Binding>customBinding</Binding>
<BindingConfiguration>CustomBinding_IReceiveNoteService</BindingConfiguration>
<Contract>ConsumerPortalAPI.IReceiveNoteService</Contract>
<ListenUriMode>Explicit</ListenUriMode>
</Endpoint>
</Endpoints>
</ServiceConfigurationInformation>
</ExtendedData>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
&#13;
这似乎能够获得正确的绑定配置,但不知道为什么它没有使用它。
P.S。所有绑定都在customBinding标记下定义。
在这方面的任何帮助将受到高度赞赏。也许有一些非常小的东西我在这里失踪了,你们中的任何一个人都可以指出我正确的方向。
提前致谢。
答案 0 :(得分:0)
我能够通过在绑定配置中添加以下行来解决此问题。
<httpsTransport maxReceivedMessageSize="2147483647"/>
&#13;
整个绑定配置现在看起来像
<binding name="CustomBinding_IReceiveNoteService" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation" requireDerivedKeys="false" includeTimestamp="false" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" canRenewSecurityContextToken="true">
<secureConversationBootstrap defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</secureConversationBootstrap>
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<binaryMessageEncoding>
<readerQuotas maxDepth="32767" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="32767" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpsTransport maxReceivedMessageSize="2147483647"/>
</binding>
&#13;