PDA

View Full Version : Double items


.ben
01-10-2007, 08:47 PM
I'm exporting a service as a webservice using the spring framework and consuming it on the client again using spring.

The items I'm returning are of the class below:



public class SovPeriod
{

private List<int> m_advertIdsMaxPrice;
private List<int> m_advertIdsMinPrice;
private decimal m_minPrice;
private decimal m_maxPrice;
private Period m_period;
private decimal m_sov;
private decimal m_count;
private decimal m_avgPrice;

public SovPeriod()
{
//m_advertIdsMaxPrice = new List<int>();
//m_advertIdsMinPrice = new List<int>();
}

public decimal Sov
{
get
{
return m_sov;
}
set
{
m_sov = value;
}
}

public decimal Count
{
get
{
return m_count;
}
set
{
m_count = value;
}
}

public decimal AvgPrice
{
get
{
return m_avgPrice;
}
set
{
m_avgPrice = value;
}
}

public Period Period
{
get
{
return m_period;
}
set
{
m_period = value;
}
}

public decimal MaxPrice
{
get
{
return m_maxPrice;
}
set
{
m_maxPrice = value;
}
}
public decimal MinPrice
{
get
{
return m_minPrice;
}
set
{
m_minPrice = value;
}
}

public List<int> AdvertIdsMaxPrice
{
get
{
return m_advertIdsMaxPrice;
}
set
{
m_advertIdsMaxPrice = value;
}
}

public List<int> AdvertIdsMinPrice
{
get
{
return m_advertIdsMinPrice;
}
set
{
m_advertIdsMinPrice = value;
}
}
}

public class SovItem
{
private string m_name;
public List<SovPeriod> m_sovCalculations;
public List<SovItem> m_childSovItems;

public SovItem()
{
//m_name = string.Empty;
//m_sovCalculations = new List<SovPeriod>();
//m_childSovItems = new List<SovItem>();
}

public string Name
{
get
{
return m_name;
}
set
{
m_name = value;
}
}

public List<SovPeriod> SovCalculations
{
get
{
return m_sovCalculations;
}
set
{
m_sovCalculations = value;
}
}

public List<SovItem> ChildSovItems
{
get
{
return m_childSovItems;
}
set
{
m_childSovItems = value;
}
}

}




The webservice returns an array of SovItems.

Now comes the fun part.
On the server the array looks like this:

aParentSovItem1
---aChild1OfParent1
---aChild2OfParent1
aParentSovItem2
---aChild3ofParent2
---aChild4ofParent2

when this array arrives on the client, it looks like this:

aParentSovItem1
---aChild1OfParent1
---aChild2OfParent1
---aChild1OfParent1
---aChild2OfParent1
aParentSovItem2
---aChild3ofParent2
---aChild4ofParent2
---aChild3ofParent2
---aChild4ofParent2

No clue how to solve this.

.ben
01-10-2007, 09:49 PM
I've overriden Equals and Gethascode to see if it had something to do with that but I still receive this strange behaviour.

Erich Eichinger
01-11-2007, 08:38 AM
Hi,

Maybe you try using an old ArrayList instead of List<T> to see if maybe the List<T> implementation is faulty?

Otherwise I don't have a clue what's going on here...

sorry,
Erich

.ben
01-11-2007, 10:00 AM
Yup, I changed the list to an old-fashioned array (arraylist would have broken too much ) and the returned list is now correct.

Aleks Seovic
01-11-2007, 12:26 PM
Really wierd... Let me know if you figure out what's going on when you use generic list. Can you try to generate client-side proxy using VS.NET and see if you still get the same behavior? That way we can at least nail down whether it's our or Microsoft's issue...

Thanks,

Aleks

.ben
01-11-2007, 01:27 PM
I'm trying to recreate the behaviour in a sample app, without any luck(?) so far.

javajunky
01-11-2007, 09:07 PM
Just thought I'd mention, I'm exposing Web Services that return List<T> elements all over the place, Spring.Net doesn't have a problem with it for me!

(FWIW: It does have a problem with IList<T> or anything that implements IDictionary<T,U>)

I'm using a recent nightly build.