The following is a simple example:
Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Namespace webservice1
{
[Serializable]
Public class person
{
Private person friend;
Private string name;
Public string name
{
Get {return name ;}
Set {name = value ;}
}
Public Person friend
{
Get {return friend ;}
Set {friend = value ;}
}
}
}
Using system;
Using system. Data;
Using system. Web;
Using system. collections;
Using system. Web. Services;
Using system. Web. Services. Protocols;
Using system. componentmodel;
Namespace webservice1
{
/// <Summary>
/// Summary description for service1
/// </Summary>
[WebService (namespace = "http://tempuri.org/")]
[Webservicebinding (conformsto = wsiprofiles. basicprofile1_1)]
[Toolboxitem (false)]
Public class service1: system. Web. Services. WebService
{
[Webmethod]
Public Person helloworld ()
{
Person him = new person ();
Person her = new person ();
Him. Friend = her;
Her. Friend = him;
Return him;
}
}
}
When you run asmx web service, the following error is returned:
System. invalidoperationexception: There was an error generating the XML
Document. --->
System. invalidoperationexception: A circular reference was detected while
Serializing an object of type person.
There is an article on the IBM websiteArticleDescribes the problem:
Http://www-106.ibm.com/developerwor...s-tip-j2eenet1/
Who have solved this problem?