System.Xml.XmlException: The maximum read depth (32) has been exceeded

Posts   
 
    
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 22-Jul-2008 00:06:43   

I'm using adapter v2.6, the only LlblGen dll I have referenced is: OrmSupportClasses 2.6.08.0709

I'm using vs2008, DotNet 3.5, WCF, HtmlBasic binding. In the client I'm retrieving a EntityCollection that was filled on the server with FetchCollection and using prefetch paths. The prefetch looks like

BillingAccount -> Customer -> BillYyyyMm BillingAccount -> BanType BillingAccount -> Company BillingAccount -> Subprovider -> Provider BillingAccount -> State

I've succesfully retrieved other EntityCollections using my service.

I'm receiving this error:


 System.Xml.XmlException: The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota. This quota may be increased by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 11813.
   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
   at System.Xml.XmlExceptionHelper.ThrowMaxDepthExceeded(XmlDictionaryReader reader, Int32 maxDepth)
   at System.Xml.XmlBaseReader.EnterScope()
   at System.Xml.XmlUTF8TextReader.ReadStartElement()
   at System.Xml.XmlUTF8TextReader.Read()
   at System.Xml.XmlBaseReader.Skip()
   at System.IdentityModel.ExclusiveCanonicalizationTransform.ProcessReaderInput(XmlReader reader, SignatureResourcePool resourcePool, HashStream hashStream)
   at System.IdentityModel.ExclusiveCanonicalizationTransform.ProcessAndDigest(Object input, SignatureResourcePool resourcePool, HashAlgorithm hash, DictionaryManager dictionaryManger)
   at System.IdentityModel.ExclusiveCanonicalizationTransform.ProcessAndDigest(Object input, SignatureResourcePool resourcePool, String digestAlgorithm, DictionaryManager dictionaryManager)
   at System.IdentityModel.TransformChain.TransformToDigest(Object data, SignatureResourcePool resourcePool, String digestMethod, DictionaryManager dictionaryManager)
   at System.IdentityModel.Reference.ComputeDigest()
   at System.IdentityModel.Reference.EnsureDigestValidityIfIdMatches(String id, Object resolvedXmlSource)
   at System.IdentityModel.StandardSignedInfo.EnsureDigestValidityIfIdMatches(String id, Object resolvedXmlSource)
   at System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.EnsureDigestValidityIfIdMatches(SignedInfo signedInfo, String id, XmlDictionaryReader reader, Boolean doSoapAttributeChecks, MessagePartSpecification signatureParts, MessageHeaderInfo info, Boolean checkForTokensAtHeaders)
   at System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.ExecuteMessageProtectionPass(Boolean hasAtLeastOneSupportingTokenExpectedToBeSigned)
   at System.ServiceModel.Security.ReceiveSecurityHeader.Process(TimeSpan timeout)
   at System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(ReceiveSecurityHeader securityHeader, Message& message, SecurityToken requiredSigningToken, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
   at System.ServiceModel.Security.InitiatorSessionSymmetricMessageSecurityProtocol.VerifyIncomingMessageCore(Message& message, String actor, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
   at System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ProcessIncomingMessage(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, MessageFault& protocolFault)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.ProcessReply(Message reply, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Cgm.DataService.Client.DataServiceReference.IWinData.GetBaseFilterInformationForCustomer(String userId, Int32 customerId)
   at Cgm.DataService.Client.DataServiceToUserInterface.GetCustomerBaseInvoiceInformation() in D:\Data\arschr\Visual Studio 2008\Projects\Cgm\Cgm.DataService.TestClient\Cgm.DataService.Client\DataServiceToUserInterface.cs:line 70
   at TestProject.DataServiceToUserInterfaceTest.TestGetBaseBillingAccountInformation() in D:\Data\arschr\Visual Studio 2008\Projects\Cgm\Cgm.DataService.TestClient\TestProject\UnitTest1.cs:line 75
   at Gallio.Utilities.ExceptionUtils.RethrowWithNoStackTraceLoss(Exception ex) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Utilities\ExceptionUtils.cs:line 97
   at Gallio.Utilities.ExceptionUtils.InvokeMethodWithoutTargetInvocationException(MethodBase method, Object obj, Object[] args) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Utilities\ExceptionUtils.cs:line 118
   at Gallio.Framework.Pattern.PatternTestInstanceState.InvokeTestMethod() in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\PatternTestInstanceState.cs:line 361
   at Gallio.Framework.Pattern.TestMethodPatternAttribute.<SetTestSemantics>b__1(PatternTestInstanceState testInstanceState) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\TestMethodPatternAttribute.cs:line 158
   at MbUnit.Framework.TestAttribute.<SetTestSemantics>b__0(PatternTestInstanceState state, Action`1 action) in c:\RelEng\Projects\MbUnit v3\Work\src\MbUnit\MbUnit\Framework\TestAttribute.cs:line 99
   at Gallio.ActionChain`1.<>c__DisplayClass1.<Around>b__0(T obj) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\ActionChain.cs:line 131
   at Gallio.Framework.Pattern.PatternTestInstanceActions.ExecuteTestInstance(PatternTestInstanceState testInstanceState) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\PatternTestInstanceActions.cs:line 182
   at Gallio.Framework.Pattern.PatternTestInstanceActions.ExecuteTestInstance(PatternTestInstanceState testInstanceState) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\PatternTestInstanceActions.cs:line 182
   at Gallio.Framework.Pattern.PatternTestInstanceActions.ExecuteTestInstance(PatternTestInstanceState testInstanceState) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\PatternTestInstanceActions.cs:line 182
   at Gallio.Framework.Pattern.PatternTestExecutor.<>c__DisplayClass26.<DoExecuteTestInstance>b__24() in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\PatternTestExecutor.cs:line 446
   at Gallio.Concurrency.ThreadAbortScope.RunWithThreadAbort(Action action) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Concurrency\ThreadAbortScope.cs:line 156
   at Gallio.Concurrency.ThreadAbortScope.Run(Action action) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Concurrency\ThreadAbortScope.cs:line 75
   at Gallio.Framework.Sandbox.RunWithScope(ThreadAbortScope scope, Action action, String description) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Sandbox.cs:line 275



I don't think I can

by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

I think I remember this error coming up before but I can't find it when I search the forums.

I seem to remember Frans saying he was going to increase the MaxDepth, but I'm not sure.

Need more information? Any thoughts?

Edit

I can make it pass by commenting prefetches. My service Method looks like this when it succeeds.


       public EntityCollection GetBaseFilterInformationForCustomer(string userId, int customerId)
        {
            EntityCollection collection = new EntityCollection(new BillingAccountEntityFactory());
            CollectionFetchParameters parms = new CollectionFetchParameters();
            parms.Collection = collection;
            parms.RelationPredicateHolder = new RelationPredicateBucket(BillingAccountFields.CustomerId==customerId);
            IPrefetchPath2 prefetch = new PrefetchPath2(EntityType.BillingAccountEntity);
            prefetch.Add(BillingAccountEntity.PrefetchPathBanType);
            prefetch.Add(BillingAccountEntity.PrefetchPathCompany_);
            IPrefetchPathElement2 ppeCustomer = prefetch.Add(BillingAccountEntity.PrefetchPathCustomer);
            IPrefetchPathElement2 ppeBillYyyyMmv2 = ppeCustomer.SubPath.Add(CustomerEntity.PrefetchPathBillYyyyMmv2);
            ppeBillYyyyMmv2.SubPath.Add(BillYyyyMmv2Entity.PrefetchPathBillYyyyMmEntity);
//         prefetch.Add(BillingAccountEntity.PrefetchPathStateEntity);
//          IPrefetchPathElement2 ppeSubprovider = prefetch.Add(BillingAccountEntity.PrefetchPathSubprovider);
//          ppeSubprovider.SubPath.Add(SubproviderEntity.PrefetchPathProviders);
            parms.PrefetchPath = prefetch;
            BaseController.FetchCollection(userId,parms);
            return collection;
        }

If I uncomment either of the first two commented out prefetches it then fails.

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 22-Jul-2008 00:39:26   

O.K. I can change this myself.

in the client side binding config.


<bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IWinData" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536000"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                   <readerQuotas maxDepth="97" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" establishSecurityContext="true" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>

there is

<readerQuotas maxDepth="97" 

By playing with this (it was 32 by default) I find that (for this particular set of prefetchs) 96 fails when all prefetches uncommented; 97 succeeds.

Does anyone have insight to how this correlates to a particular graph of prefetch nodes?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Jul-2008 06:28:51   

arschr wrote:

97 succeeds

So, Does it work now?

These type on configuration values, such as timeouts, quatas, et cetera, are considered internal implementation elements of the service that could be configured at the ServiceModel config section.

David Elizondo | LLBLGen Support Team
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 22-Jul-2008 12:40:48   

So, Does it work now?

Yes.

By playing with this (it was 32 by default) I find that (for this particular set of prefetchs) 96 fails when all prefetches uncommented; 97 succeeds.

For this one particular method at least.

My current question is:

Does anyone have insight to how this correlates to a particular graph of prefetch nodes?

So how does this configuration level relate to the shape of the prefetch? More directly, for a given set of prefetches how can I calculate what depth I need to place in the configuration without trial and error?

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 22-Jul-2008 15:35:18   

The read-depth is likely caused by recursion: Customer X has Order Y, Y refers to Employee E, E has also done Order Y2, Y2 is filed by customer X2, X2 has more orders etc. etc.

Every entity is serialized through recursion: when the customer X is serialized, its Orders collection is also serialized, by serializing the Order instances one by one. The first order to serialize has to complete before the second can be serialized, so the call path goes on and on.

(Edit)

So how does this configuration level relate to the shape of the prefetch? More directly, for a given set of prefetches how can I calculate what depth I need to place in the configuration without trial and error?

I couldn't find enough infromation about this number, but in most samples posted on the net, people are using larger numbers, 512 is the least.

So I think it's a trial and error, to find the least maxdepth you need. Otherwise I don't know if it's wise to XML-serialize the graph into a file and manually count the nested entity tags.

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 22-Jul-2008 16:27:01   

Ok, Thanks.

WCF sure provides a lot of configuration options!