C# WCF:读取XML数据时已超过最大数组长度配额(16384)
我知道这已经被问了好几次了,相信我,我已经花了大半个下午的时间看了很多,试了很多次,但仍然无法克服 我试图通过web服务提交一些表单内容(也可以包括附件),但当我尝试附加除小文件以外的任何内容时,会出现以下错误 我的全部错误是: 格式化程序在尝试反序列化 消息:尝试反序列化参数时出错 . InnerException消息是“存在” 反序列化类型的对象时出错 MashForms.Models.SCChildrenForm。最大数组长度配额 读取XML数据时已超过(16384)。这个配额可能是 通过更改上的MaxArrayLength属性增加 创建XML读取器时使用的XmlDictionaryReaderQuotas对象。 第1行,位置41713“。有关更多详细信息,请参阅InnerException 无论我如何尝试在WCF服务的web.config和web客户端中重写该值,它仍然会将其报告为最大错误,并随后报告错误 wcfweb.Config 更新2:根据建议添加了服务端点C# WCF:读取XML数据时已超过最大数组长度配额(16384),c#,.net,wcf,web-services,wcf-binding,C#,.net,Wcf,Web Services,Wcf Binding,我知道这已经被问了好几次了,相信我,我已经花了大半个下午的时间看了很多,试了很多次,但仍然无法克服 我试图通过web服务提交一些表单内容(也可以包括附件),但当我尝试附加除小文件以外的任何内容时,会出现以下错误 我的全部错误是: 格式化程序在尝试反序列化 消息:尝试反序列化参数时出错 . InnerException消息是“存在” 反序列化类型的对象时出错 MashForms.Models.SCChildrenForm。最大数组长度配额 读取XML数据时已超过(16384)。这个配额可能是 通过
但是我仍然有同样的错误。您已经定义了一个“BasicHttpBinding\u IInsertNewForm”绑定,但是您是否真的将此绑定连接到您的服务?你是用密码做的吗?如果是,请张贴代码。因为我没有在你的配置中看到它。。。通常,在绑定实际连接到服务的部分中会有一个部分。它只是一个使用wsHttpBinding的来宾。 您可以在web.config中编写以下代码
<wsHttpBinding>
<binding name="MyBinding" maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
谢谢你的建议。不幸的是,所有的建议都没有解决这个问题,它似乎仍然从某个地方获得了一个超越它的值 我通过自定义绑定的方式,成功地处理了更大的文件
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MashPortalService.MyServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceTimeouts transactionTimeout="05:05:00" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="2147483647" />
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!--<serviceMetadata httpsGetEnabled="true"/>-->
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<!--<StructureMapServiceBehavior />-->
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
<extensions>
<behaviorExtensions>
</behaviorExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="MashCustomBinding"
closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<textMessageEncoding messageVersion="Soap11" maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="MashPortalService.MyServiceBehaviour" name="MashPortalService.InsertNewForm">
<endpoint address="" binding="customBinding"
bindingConfiguration="MashCustomBinding" contract="MashPortalService.IInsertNewForm" />
</service>
</services>
</system.serviceModel>
我添加了一个更新1,我想这就是你的意思。谢谢你的回复@Eugene Osovetsky也一样,正如我所提到的,它适用于<12k的小文件,所以我认为该位一定是正常的?不,这不是我的意思。。。服务如何知道它应该使用您定义的“BasicHttpBinding_IInsertNewForm”绑定?我在你的帖子里没有看到任何这样的东西。尝试将适当的服务部分添加到配置中,看看是否有帮助。看看第一个答案是怎么做的啊,像这样?当我尝试更新Web应用程序的引用时,它会出错。在您的情况下,它必须是basicHttpBinding,而不是WSHttpBinding。不幸的是,这没有什么区别,它仍然会抛出相同的错误。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IInsertNewForm" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:54070/MashPortalService/InsertNewForm.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInsertNewForm"
contract="InsertNewForm.IInsertNewForm" name="BasicHttpBinding_IInsertNewForm" />
</client>
</system.serviceModel>
using System.ServiceModel;
using MashForms.Models;
namespace MashPortalService
{
[ServiceContract]
public interface IInsertNewForm
{
//Testing operations
[OperationContract]
string TestReturnInput(string s);
[OperationContract]
bool Ping();
//Child
[OperationContract]
int InsertFormChildGettingIdBack(SCChildrenForm scChildForm);
}
}
</bindings>
<services>
<service name="MashPortalService">
<endpoint address="http://localhost:54070/MashPortalService/InsertNewForm.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IInsertNewForm" contract="InsertNewForm.IInsertNewForm" />
</service>
</services>
<wsHttpBinding>
<binding name="MyBinding" maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MashPortalService.MyServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceTimeouts transactionTimeout="05:05:00" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="2147483647" />
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!--<serviceMetadata httpsGetEnabled="true"/>-->
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<!--<StructureMapServiceBehavior />-->
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
<extensions>
<behaviorExtensions>
</behaviorExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="MashCustomBinding"
closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<textMessageEncoding messageVersion="Soap11" maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="MashPortalService.MyServiceBehaviour" name="MashPortalService.InsertNewForm">
<endpoint address="" binding="customBinding"
bindingConfiguration="MashCustomBinding" contract="MashPortalService.IInsertNewForm" />
</service>
</services>
</system.serviceModel>