Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2006

Tip: Looking for answers? Try searching our database.

how to make webmethod output my object class?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xisco - 13 Feb 2006 07:34 GMT
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/

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.