You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Andrew Hawkes <ha...@quy-su.org> on 2003/12/26 08:43:36 UTC

circular references

I'm having a problem with circular references during serialization.

For example, say I have two types: User and Group. User has a 
getGroup() method, and Group has a getUsers() method which returns an 
array of users.

Since this basically amounts to a circular reference, Axis goes into 
infinite recursion when it tries to serialize the response, and simply 
hangs forever spitting out huge log messages.

It seems like SOAP should have a more intelligent way to handle this. 
Is there a known solution, other than removing the circular reference 
from my objects?

Thanks,
Andrew


Re: circular references

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
I don't know of any prohibition against circular references in the SOAP 
encoding specification. AFAIKS this is an Axis bug (unfortunately one 
that's likely to be nasty to fix, given the assumptions made by the 
current architecture).

  - Dennis

Robert van Engelen wrote:

>Hi,
>
>There are SOAP toolkits that can handle cycles automatically.
>
>Try gSOAP (for C/C++) for example, it handles cycles intelligently and 
>does not waste space (producing id-refs only when necessary).
>
>- Robert
>
>On Friday, December 26, 2003, at 11:28 AM, Chandrasegaram Jeyakumaran 
>wrote:
>
>  
>
>>Hi,
>>
>>Yes(bit interested :) ), I agree with Aaron and the concept can be
>>implemented in a handler(so it is a serialization part) and we can 
>>call it
>>whenever the recursion is occured(provided that developer should be
>>capable of prediction the circular references).]
>>
>>regards,
>>Jeyakumaran
>>
>>    
>>
>>>I can't answer for Axis, but this is one of the problems with XML 
>>>being
>>>a unidirectional tree.  The only way to do this in XML (that I am 
>>>aware
>>>of) is use 'id' attributes and then refer to those id attributes in
>>>subsequent tags (you'll note this problem is similar in
>>>object-relational mapping).  You could have either User or Group 
>>>object
>>>(or both) not contain references to each other but merely unique ids 
>>>to
>>>the respective object...or implement custom serializers to perform 
>>>this
>>>under the covers.
>>>
>>>Aaron
>>>
>>>Andrew Hawkes wrote:
>>>
>>>      
>>>
>>>>I'm having a problem with circular references during serialization.
>>>>
>>>>For example, say I have two types: User and Group. User has a
>>>>getGroup() method, and Group has a getUsers() method which returns an
>>>>array of users.
>>>>
>>>>Since this basically amounts to a circular reference, Axis goes into
>>>>infinite recursion when it tries to serialize the response, and 
>>>>simply
>>>> hangs forever spitting out huge log messages.
>>>>
>>>>It seems like SOAP should have a more intelligent way to handle this.
>>>>Is there a known solution, other than removing the circular reference
>>>>from my objects?
>>>>
>>>>Thanks,
>>>>Andrew
>>>>        
>>>>
>>Lanka Software Foundation
>>Promoting opensource in Srilanka
>>
>>
>>    
>>
>
>  
>


Re: circular references

Posted by Robert van Engelen <en...@cs.fsu.edu>.
Hi,

There are SOAP toolkits that can handle cycles automatically.

Try gSOAP (for C/C++) for example, it handles cycles intelligently and 
does not waste space (producing id-refs only when necessary).

- Robert

On Friday, December 26, 2003, at 11:28 AM, Chandrasegaram Jeyakumaran 
wrote:

> Hi,
>
> Yes(bit interested :) ), I agree with Aaron and the concept can be
> implemented in a handler(so it is a serialization part) and we can 
> call it
> whenever the recursion is occured(provided that developer should be
> capable of prediction the circular references).]
>
> regards,
> Jeyakumaran
>
>> I can't answer for Axis, but this is one of the problems with XML 
>> being
>> a unidirectional tree.  The only way to do this in XML (that I am 
>> aware
>> of) is use 'id' attributes and then refer to those id attributes in
>> subsequent tags (you'll note this problem is similar in
>> object-relational mapping).  You could have either User or Group 
>> object
>> (or both) not contain references to each other but merely unique ids 
>> to
>> the respective object...or implement custom serializers to perform 
>> this
>> under the covers.
>>
>> Aaron
>>
>> Andrew Hawkes wrote:
>>
>>> I'm having a problem with circular references during serialization.
>>>
>>> For example, say I have two types: User and Group. User has a
>>> getGroup() method, and Group has a getUsers() method which returns an
>>> array of users.
>>>
>>> Since this basically amounts to a circular reference, Axis goes into
>>> infinite recursion when it tries to serialize the response, and 
>>> simply
>>>  hangs forever spitting out huge log messages.
>>>
>>> It seems like SOAP should have a more intelligent way to handle this.
>>> Is there a known solution, other than removing the circular reference
>>> from my objects?
>>>
>>> Thanks,
>>> Andrew
>
>
> Lanka Software Foundation
> Promoting opensource in Srilanka
>
>


Re: circular references

Posted by Chandrasegaram Jeyakumaran <jk...@opensource.lk>.
Hi,

Yes(bit interested :) ), I agree with Aaron and the concept can be
implemented in a handler(so it is a serialization part) and we can call it
whenever the recursion is occured(provided that developer should be
capable of prediction the circular references).]

regards,
Jeyakumaran

> I can't answer for Axis, but this is one of the problems with XML being
> a unidirectional tree.  The only way to do this in XML (that I am aware
> of) is use 'id' attributes and then refer to those id attributes in
> subsequent tags (you'll note this problem is similar in
> object-relational mapping).  You could have either User or Group object
> (or both) not contain references to each other but merely unique ids to
> the respective object...or implement custom serializers to perform this
> under the covers.
>
> Aaron
>
> Andrew Hawkes wrote:
>
>> I'm having a problem with circular references during serialization.
>>
>> For example, say I have two types: User and Group. User has a
>> getGroup() method, and Group has a getUsers() method which returns an
>> array of users.
>>
>> Since this basically amounts to a circular reference, Axis goes into
>> infinite recursion when it tries to serialize the response, and simply
>>  hangs forever spitting out huge log messages.
>>
>> It seems like SOAP should have a more intelligent way to handle this.
>> Is there a known solution, other than removing the circular reference
>> from my objects?
>>
>> Thanks,
>> Andrew


Lanka Software Foundation
Promoting opensource in Srilanka



Re: circular references

Posted by Aaron Hamid <ar...@cornell.edu>.
I can't answer for Axis, but this is one of the problems with XML being 
a unidirectional tree.  The only way to do this in XML (that I am aware 
of) is use 'id' attributes and then refer to those id attributes in 
subsequent tags (you'll note this problem is similar in 
object-relational mapping).  You could have either User or Group object 
(or both) not contain references to each other but merely unique ids to 
the respective object...or implement custom serializers to perform this 
under the covers.

Aaron

Andrew Hawkes wrote:

> I'm having a problem with circular references during serialization.
>
> For example, say I have two types: User and Group. User has a 
> getGroup() method, and Group has a getUsers() method which returns an 
> array of users.
>
> Since this basically amounts to a circular reference, Axis goes into 
> infinite recursion when it tries to serialize the response, and simply 
> hangs forever spitting out huge log messages.
>
> It seems like SOAP should have a more intelligent way to handle this. 
> Is there a known solution, other than removing the circular reference 
> from my objects?
>
> Thanks,
> Andrew
>