-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Using webservices with NHibernate: serializing an ISet?
PostPosted: Thu Jul 06, 2006 11:47 am 
Newbie

Joined: Thu Jun 29, 2006 11:49 am
Posts: 13
Hello. I am using NHibernate 1.2 Alpha.

I am using ISet<T> lists on my data objects.

I have made a webservice that returns one of this objects and the result is:

Cannot serialize member IriSceneRemoteManager.DataModel.IrmTerminal.Groups of type Iesi.Collections.Generic.ISet`1[[IriSceneRemoteManager.DataModel.IrmTerminalGroup, DataModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface

Is there a way to exchange NHibernate objects between webservice server/clients?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 12:54 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
I tried doing the same thing with an IList<T> and ran into the same problem. The solution for me was to use the non-generic IList instead. For whatever reason, the generic version doesn't work but the non-generic version does. I've never tried ISet, but, I'm guessing the solution may be the same for that.

From what I've heard, generic ILists work if you use Windows Communication Foundation (WCF). I haven't tried it yet myself though, so, I can't verify whether it's true.


Top
 Profile  
 
 Post subject: Serializing IList
PostPosted: Tue Apr 24, 2007 4:31 pm 
Beginner
Beginner

Joined: Fri Jul 14, 2006 1:51 pm
Posts: 27
You can't serialize an interface. You can do something like this though:

Code:
[WebMethod]
    public List<Story> GetStoriesBySubmittingUser( int userID )
    {
        return NHDaoFactory.GetStoryDao().GetByUser( userID ) as List<Story>;
    }


NHDaoFactory.GetStoryDao().GetByUser( userID ) returns an IList.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 4:03 am 
Beginner
Beginner

Joined: Tue May 02, 2006 8:04 am
Posts: 34
Allthough your function returns an IList, your cast will only work if indeed the implementation returned is a List<Story>. If you're returning an array your cast will 'fail' and since you are using the as statement return null.

Webmethods need to know implementations not supported behaviour (interface).


Top
 Profile  
 
 Post subject: IList as List
PostPosted: Wed Apr 25, 2007 10:00 am 
Beginner
Beginner

Joined: Fri Jul 14, 2006 1:51 pm
Posts: 27
I should have pointed out I'm using generic collections throughout. So it returns IList<Story> which can be cast to List<Story> with no issues.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.