Hi all
I am new to .NET and webservice so I wish someone can shed some light
on me.
I have a Project class and a Product class, the Project can contain
multiple Products (as an ArrayList). In my WebMethod I Initialize my
project as following:
<WebMethod()> Public Function ProjectInitial( )
As Project
'Public Function ProjectInitial( ByVal inputProduct As
Product) As Project
Dim myProject As New Project
myProject = InitialProject( "Test Project")
Dim myProduct As New Product
myProduct.cost = 100
myProduct.maste rQty = 1000
Dim myProduct2 As New Product
myProduct2.cost = 200
myProduct2.mast erQty = 2000
myProject.AddFi nishProduct(myP roduct)
myProject.AddFi nishProduct(myP roduct2)
Return myProject
End Function
The following is the structure of my Project class
[code:1:bb159c48 1b]
Imports System.Xml.Seri alization
<XmlInclude(Get Type(Product))> Public Class
Project
#Region " Project Properties "
Public projectID As Int32
Public projectName As String
Public projectStatus As Int32
Public projectCreateDa te As DateTime
Public projectModifyDa te As DateTime
Public ProductList As New ArrayList
#End Region
Public Sub AddFinishProduc t(ByVal inputProduct As
Product)
'Add Product into the arraylist "ProductLis t "
....
....
End Sub
End Class
[/code:1:bb159c48 1b]
The following is the structure of my Product class
[code:1:bb159c48 1b]
Imports System.Xml.Seri alization
<XmlInclude(Get Type(Properties )),
SoapInclude(Get Type(Product))> Public Class
Product
' Product properties
Public masterQty As Int32
Public cost As Double ' temperary cost, will use config costs to
replace
Public PropertyList As New ArrayList
' ArrayList stores it's component product
Public componentProduc t As New ArrayList
Public Sub AddProduct(ByVa l inputProduct As Product)
'Add Product object into componentProduc t
....
....
End Sub
End Class
[/code:1:bb159c48 1b]
As you can see the I wish the Product can also contain a list of
Products because in my logic some Product can be constructed by a
list of Component Product but I want them to be in the same structure
because they have the same properties, also a Component Product can be
constructed by other Component Product.
If I don't add Product object into the Product, every
thing goes ok. But if I add a Project object inside a Product I have
the following error message
System.InvalidO perationExcepti on: There was an error
generating the XML document. --->
System.InvalidO perationExcepti on: A circular reference was detected
while serializing an object of type
ProjectInitiali ze.Product.
Is there any work around I can do to solve the problem? :?
Thanks in advance for your tips 1 6473
Has anyone found a solution to this web service circular reference problem?
Here's a simplified example:
Person him=new Person();
Person her=new Person();
him.Friend=her;
her.Friend=him;
Now try to serialize one of those object through an ASMX web service and
you'll get the following:
System.InvalidO perationExcepti on: There was an error generating the XML
document. --->
System.InvalidO perationExcepti on: A circular reference was detected while
serializing an object of type Person.
This article on IBM's site implies that .NET can do this somehow: http://www-106.ibm.com/developerwork...-tip-j2eenet1/
Any ideas?
-Ben http://www.benday.com
"dotnetnewb ie" wrote: Hi all
I am new to .NET and webservice so I wish someone can shed some light on me.
I have a Project class and a Product class, the Project can contain multiple Products (as an ArrayList). In my WebMethod I Initialize my project as following:
<WebMethod()> Public Function ProjectInitial( ) As Project
'Public Function ProjectInitial( ByVal inputProduct As Product) As Project Dim myProject As New Project myProject = InitialProject( "Test Project")
Dim myProduct As New Product myProduct.cost = 100 myProduct.maste rQty = 1000
Dim myProduct2 As New Product myProduct2.cost = 200 myProduct2.mast erQty = 2000 myProject.AddFi nishProduct(myP roduct) myProject.AddFi nishProduct(myP roduct2)
Return myProject End Function
The following is the structure of my Project class
[code:1:bb159c48 1b]
Imports System.Xml.Seri alization
<XmlInclude(Get Type(Product))> Public Class Project
#Region " Project Properties "
Public projectID As Int32 Public projectName As String Public projectStatus As Int32 Public projectCreateDa te As DateTime Public projectModifyDa te As DateTime
Public ProductList As New ArrayList
#End Region
Public Sub AddFinishProduc t(ByVal inputProduct As Product) 'Add Product into the arraylist "ProductLis t " .... .... End Sub End Class [/code:1:bb159c48 1b]
The following is the structure of my Product class
[code:1:bb159c48 1b]
Imports System.Xml.Seri alization
<XmlInclude(Get Type(Properties )), SoapInclude(Get Type(Product))> Public Class Product ' Product properties Public masterQty As Int32 Public cost As Double ' temperary cost, will use config costs to replace Public PropertyList As New ArrayList
' ArrayList stores it's component product Public componentProduc t As New ArrayList
Public Sub AddProduct(ByVa l inputProduct As Product) 'Add Product object into componentProduc t .... .... End Sub End Class [/code:1:bb159c48 1b]
As you can see the I wish the Product can also contain a list of Products because in my logic some Product can be constructed by a list of Component Product but I want them to be in the same structure because they have the same properties, also a Component Product can be constructed by other Component Product.
If I don't add Product object into the Product, every thing goes ok. But if I add a Project object inside a Product I have the following error message
System.InvalidO perationExcepti on: There was an error generating the XML document. ---> System.InvalidO perationExcepti on: A circular reference was detected while serializing an object of type ProjectInitiali ze.Product.
Is there any work around I can do to solve the problem? :?
Thanks in advance for your tips
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vera |
last post by:
I have two assemblies that each consist of several classes.
Each object instantiated from those classes can have one or more child- and/or parentobjects that are also instantiated from those classes. Most relationships exist within one assembly, but relationships between assemblies may sometimes occur. For each relationship, I have to make sure that an object from Class1 knows that it can have an object from Class2 as one of its children....
|
by: Steve Jorgensen |
last post by:
I just came up with a really tidy little solution to the VB/VBA circular
reference issue. It only works with Access 2000 or newer, but that's about
the only down-side.
The issue...
You need an object model that includes a container object, and the object in
the container need to interact with the container itself. The problem is
that, to access the container, each item needs a reference to the container,
and that constitutes a...
|
by: T Koster |
last post by:
After a few years of programming C, I had come to believe that I finally
knew how to correctly organise my structure definitions in header files
for mutually dependent structures, but I find myself stumped again with
this little love triangle. Here is some background:
m_commands.h defines
- struct command_callbacks, which contains
- a struct conn * reference
- struct command, which contains
- a struct command_callback reference
|
by: Henke |
last post by:
I have this scenario.
public class A
{
public int numbers;
public class A()
{
}
|
by: Frank Rizzo |
last post by:
I have a circular reference between 2 classes in the same project (i.e.
each class refers to the other). The app runs fine and I am seeing no
issues, which kind of surprised me.
Are there any issues that I am not seeing (performance wise or garbage
collection wise) with circular references?
Thanks.
| |
by: Stephen Robertson |
last post by:
We are currently in a dead end with a circular reference issue using
vb.net, and are hoping someone might help us resolve it.
Idea...
We have frmmain calling frmperson (dim f as new frmperson) in search
(no record) mode. When the search is executed, frmperson calls
frmsearchresult (dim f as new frmsearchresult) which is a listing of
persons. From frmsearchresults, frmperson is called (dim f as new
frmperson) with the resulting...
|
by: Solution Seeker |
last post by:
Hi All,
I am here with a Query and need a Solution for it.
The Query is as Follows,
We have 3 Projects in a Solution - Say UI, CMN and PRD
First One Deals with UI Forms
Second One Deals with Common Functions that are needed for the Solution
|
by: Jeremy Kitchen |
last post by:
I have inherited a project and I am trying to figure out why the
failing units tests that exist fail. I a, getting the following error
when I attempt serialization.
Any advice on what I should do to find the source of the problem would
be appreciated.
Thank you
Jeremy
|
by: =?Utf-8?B?UGF1bCBIYWxl?= |
last post by:
Moving all User Controls to a single directory has solved my problem - Thanks
Eliyahu.
That said, I still got one Circular ref error yesterday, rebuilt again and
the build was fine? Far far better than the amount of errors I was originally
getting on builds before I consilidated by UC's though :-)
"Paul Hale" wrote:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |