Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > how to make webmethod output my object class?

Reply
Thread Tools

how to make webmethod output my object class?

 
 
xisco
Guest
Posts: n/a
 
      02-13-2006
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


 
Reply With Quote
 
 
 
 
xisco
Guest
Posts: n/a
 
      02-13-2006
BTW, the problem is that I get a message telling that HashTable can not be
serialized.



"xisco" <(E-Mail Removed)> wrote in message
news:u8zsf$(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Josh Twist
Guest
Posts: n/a
 
      02-13-2006
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/

 
Reply With Quote
 
xisco
Guest
Posts: n/a
 
      02-14-2006
yes, that was the problem. I will find another collection for it then.
thanks

Xis

"Josh Twist" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>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/
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Passing an object containing multiple DataSet's to a WebMethod MuZZy ASP .Net Web Services 1 03-24-2006 12:12 PM
Problem with a method, of an object, that a webmethod returns.. RCS ASP .Net Web Services 3 08-08-2005 05:57 PM
WebMethod returning a object in a COM dll chirath@flashmail.com ASP .Net Web Services 3 02-17-2005 05:56 AM
How to ignore the base class of an object returned from a webmethod Q ASP .Net Web Services 0 10-28-2003 05:15 PM



Advertisments