我有一个 WCF 服务操作,它接受字节数组作为其数据协定的一部分。该服务仅在内部公开(不公开到互联网),我想增加配额以允许 10MB 字节数组。
该服务托管在 IIS7 中。当我尝试发送超过默认长度的字节数组时,我收到以下异常消息:
反序列化类型的对象时出错
MyService.ServiceContracts.Data。最大数组长度配额
读取 XML 数据时超出 (16384)。这个配额可能是
通过更改 MaxArrayLength 属性来增加
创建 XML 读取器时使用的 XmlDictionaryReaderQuotas 对象。
第 1 行,位置 22991。
这是配置:
<system.serviceModel>
<netTcpBinding>
<binding name="largeBinaryBinding" maxReceivedMessageSize="10001000"
maxBufferPoolSize="80008000" maxBufferSize="10001000"
receiveTimeout="00:01:00" openTimeout="00:01:00"
closeTimeout="00:01:00" sendTimeout="00:01:00">
<readerQuotas maxArrayLength="10000000" />
</binding>
</netTcpBinding>
<services>
<service name="MyService">
<endpoint binding="netTcpBinding"
bindingConfiguration="largeBinaryBinding"
bindingNamespace="http://my.services.co.uk/MyService"
contract="Services.MyService.ServiceContracts.IMyService" />
</service>
</services>
</system.serviceModel>
所以我的配置允许更大的消息,但 IIS 似乎忽略了这一点 - 我如何阻止它并允许大消息通过?
再说一遍,在我发布问题后,我就找到了答案!
使用WAS时,需要在配置的服务名称中指定服务的完整类名。因此,在我的示例中,我将服务实现类称为MyService
,在命名空间中Services
。因此,在配置中,我需要
<service name="Services.MyService">
...
否则 IIS 会默默地忽略您精心设计的配置!多么方便啊。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)