I have used WCF service with my web forms.I have a page that searches records based on the filters.When my records to be fetched exceeds 8000, then it throws error as
"The underlying connection was closed: The connection was closed unexpectedly".
The services returns the data but at the interface level it throws the above error. i have tried using the below code in the Client web.config
There was an error while trying to serialize parameter http://tempuri.org/:GetUserSearchDetailsResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65535'. Change the object graph or
increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details.
Looks like the quota is not getting applied somehow. I believe the exception is seen on the client right? Could you please send me your client configuration at
piyush.joshi@microsoft.com?
Let me know if you still facing the problem after the changes to the config about specifying named behaviorConfiguration section we discussed over email.
Rashmita Sah...
Member
8 Points
7 Posts
WCF Service throws error when returning large records
Dec 02, 2011 09:58 AM|LINK
Hi ,
I have used WCF service with my web forms.I have a page that searches records based on the filters.When my records to be fetched exceeds 8000, then it throws error as "The underlying connection was closed: The connection was closed unexpectedly".
The services returns the data but at the interface level it throws the above error. i have tried using the below code in the Client web.config
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
and have set the maxReceivedMessageSize,maxBufferPoolSize,maxBufferSize etc as '2147483647' , but still the error persists.
Can anyone help me with this problem.
Thanks.
PiyushJo
Member
64 Points
17 Posts
Re: WCF Service throws error when returning large records
Dec 02, 2011 06:07 PM|LINK
Hi Rashmita,
Try using WCF tracing - http://msdn.microsoft.com/en-us/library/ms733025.aspx. That should help you in figuring out exactly which quota was exceeded in your scenario.
Thanks.
Rashmita Sah...
Member
8 Points
7 Posts
Re: WCF Service throws error when returning large records
Dec 06, 2011 07:01 AM|LINK
Hi,
Thank yoy for your reply.
I have checked my trace log. It was showing the following error :
Exception Type :
System.Runtime.Serialization.SerializationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message :
There was an error while trying to serialize parameter http://tempuri.org/:GetUserSearchDetailsResult. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65535'. Change the object graph or increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details.
stack trace :
System.Runtime.Serialization.XmlObjectSerializerContext.IncrementItemCount(Int32 count)
WriteUserSearchDTOToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContextComplex.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
WriteArrayOfUserSearchDTOToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract )
System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContextComplex.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
WriteUserSearchDTOToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.SerializeParameterPart(XmlDictionaryWriter writer, PartInfo part, Object graph)
Where as i have set maxItemsInObjectGraph="2147483647" in both client's and host's web.config.
Any other config settings that i need to change or any other way to solve this problem will be needfull.
Thanks.
PiyushJo
Member
64 Points
17 Posts
Re: WCF Service throws error when returning large records
Dec 07, 2011 04:52 AM|LINK
Looks like the quota is not getting applied somehow. I believe the exception is seen on the client right? Could you please send me your client configuration at piyush.joshi@microsoft.com?
Rashmita Sah...
Member
8 Points
7 Posts
Re: WCF Service throws error when returning large records
Dec 08, 2011 10:17 AM|LINK
Hi,
As per your suggestion i have tried the following code.
<client>
<endpoint address="http://localhost:8732/UserService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IUserService" contract="UserServiceProxy.IUserService"
name="BasicHttpBinding_IUserService" behaviorConfiguration="myBehavior"/>
</client>
<behaviors>
<serviceBehaviors>
<behavior >
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="myBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
I added the line behaviourConfiguration on my client's web.config , but it didn't work.
For trial purpose i have used behavoiurconfiguration in my servuce web.config also but it threw an error
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
Any other method to solve this problem.
Thanks.
PiyushJo
Member
64 Points
17 Posts
Re: WCF Service throws error when returning large records
Dec 12, 2011 07:04 PM|LINK
Hi Rashmita,
Let me know if you still facing the problem after the changes to the config about specifying named behaviorConfiguration section we discussed over email.
Thanks.