我遇到了众所周知的WCF错误:
已超出传入邮件的最大邮件大小限额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。
在阅读了Google错误的前五个结果后,我仍然不知道我的服务/客户端配置可能出现什么问题。
我尝试过:
Ensuring the values are the same for the client and the server.
请注意:
正确传输小邮件,但是当从客户端向服务器发送大邮件时会发生上述错误。
过大的消息包含一个≈350KB字节数组(假设WCF配置为将二进制数据编码为base64)。
这是(1)双向通信,(2)使用网络TCP绑定(3)可靠会话和(4)排序设置(这四点与我见过的每个例子不同错误)。
该服务由随Visual Studio 2012安装的IIS Express托管。
这是我的配置。任何提示?
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<bindings>
<netTcpBinding>
<binding name="netTcpEndpoint"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="DebugOrientedBehavior"
name="DemoNamespace.PipeService">
<endpoint address="Default.svc"
binding="netHttpBinding"
name="TransportLayerServiceEndpoint"
contract="DemoNamespace.IPipeService" />
<host>
<baseAddresses>
<add baseAddress="http://example.com/Default.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DebugOrientedBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
客户端配置就是这个:
<bindings>
<netHttpBinding>
<binding name="TransportLayerServiceEndpoint"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true"
enabled="false" />
<webSocketSettings transportUsage="Always" />
</binding>
</netHttpBinding>
</bindings>
<client>
<endpoint address="ws://example.com/Default.svc/Default.svc"
binding="netHttpBinding"
bindingConfiguration="TransportLayerServiceEndpoint"
contract="PipeServiceReference.IPipeService"
name="TransportLayerServiceEndpoint" />
</client>
答案 0 :(得分:2)
您的服务配置似乎有问题 - 您为没有bindingConfiguration的服务端点指定netHttpBinding
,并且您为netTcpBinding
定义了配置(但显然未使用)。您的配置的相关服务部分在这里:
<endpoint address="Default.svc"
binding="netHttpBinding"
name="TransportLayerServiceEndpoint"
contract="DemoNamespace.IPipeService" />
请注意,没有设置bindingConfiguration
值。我建议将客户端中定义的绑定配置添加到服务配置中,然后更新服务端点以使用该绑定:
<endpoint address="Default.svc"
binding="netHttpBinding"
bindingConfiguration="TransportLayerServiceEndpoint"
name="TransportLayerServiceEndpoint"
contract="DemoNamespace.IPipeService" />
目前您的服务使用netHttpBinding
的默认值,这可能是您仍然收到错误的原因。