hi,
I want to make my webmethod return my defined object and later it will be
consumed by a java client, so I did this very simple test.
In the webmethod I do:
[WebMethod]
public myClass GetMyClass()
{
myClass output = new myClass();
return output;
}
and this is my class:
public myClass : ISerializable
{
public myClass()
{
}
private int _item1 = -1;
public int Item1
{
get{return _item1;}
set{_item1 = value;}
}
private HashTable _list1 = new HastTable()
public HashTable List1
{
get{return _list1;}
set{_list1 = value;}
}
void ISerializable.GetObjectData( SerializationInfo info,
StreamingContex context)
{
info.SetType(typeof(myClass));
}
}
but this is not working. What I am missing here? is this the correct
approach?
Xis
xisco - 13 Feb 2006 08:16 GMT
BTW, the problem is that I get a message telling that HashTable can not be
serialized.
> hi,
> I want to make my webmethod return my defined object and later it will be
[quoted text clipped - 39 lines]
>
> Xis
Josh Twist - 13 Feb 2006 13:44 GMT
I think the problem is because your inherits ISerializable - but the
hashtable can't be serialized. If you remove the derived class you
won't have the problem. Does your class have to be serializable? (If
does, you can't have a Hashtable publicly accessible).
Josh
http://www.thejoyofcode.com/
xisco - 14 Feb 2006 06:07 GMT
yes, that was the problem. I will find another collection for it then.
thanks
Xis
>I think the problem is because your inherits ISerializable - but the
> hashtable can't be serialized. If you remove the derived class you
[quoted text clipped - 3 lines]
> Josh
> http://www.thejoyofcode.com/