使用 WCF 的 ASP.NET 应用程序存在特定问题。我的数据库中有一个表,其中包含用于图像存储的二进制字段。我可以毫无问题地使用.net实体读取和写入图像的二进制数组。但是当我使用 WCF 时,出现了一些问题。
更改我的 Web 应用程序的 web.config(增加数组配额)我解决了使用 WCF 读取二进制数组的问题,但使用 WCF 写入此数组仍然存在问题。我有这样的消息:
格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数 http://tempuri.org/:question时出错。InnerException 消息是“反序列化 SL.DTO.QuestionDTO 类型的对象时出错。读取 XML 数据时已超出最大数组长度配额 (16384)。可以通过更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas 对象的 MaxArrayLength 属性来增加此配额。第 1 行,位置 55410.'。
这是我的 WEB 应用程序的 web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDAI_ExamenationService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:22840/DAI_ExamenationService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDAI_ExamenationService"
contract="DAI_ExamenationServiceReference.IDAI_ExamenationService"
name="BasicHttpBinding_IDAI_ExamenationService" />
</client>
</system.serviceModel>
这是服务应用程序的 web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
我想我应该更改服务的 web.config 中的权限来解决这个问题,但不知道哪些是......真的