472,993 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

webservice & nhibernate

Hi all,

I'm trying to set up a .NET webservice using in data access layer
Nhibernate (nhib 1.2.0 beta).
The first trouble I met was that a webservice cannot serialize
Interfaces, like IList<>.

After I workarounded it, now I get:

System.InvalidOperationException: There was an error generating the XML
document. ---System.InvalidOperationException:
CProxyType<<My_NamespaceNAme>><<MyclassName>>_NHib ernate_ProxyINHibernateProxy_System_Runtime_Serial izationISerializable2
cannot be serialized because it does not have a parameterless constructor.
at System.Xml.Serialization.TypeDesc.CheckSupported()
There is anyone out there using nhibernate for webservices??

Thanks.
Regards

gaddoz

Nov 20 '06 #1
5 9516
Hi,

Using the NHibernate entities as messages for a web service is not a good
approach. The client will only receive a xml copy of the entire entity
graph, which sometimes can involve many tables. (It is not going to receive
the entity itself).
In addition, you will have the serialization problems that you mention. It
is better to have a different class representing the web service message (A
simple class decorated with XML serialization attributes) and an adapter
layer that maps the message with the NHibernate entity.

Regards,
Pablo Cibraro.

"gaddoz" <ga************@ANTISPAMgmail.comwrote in message
news:45***********************@reader4.news.tin.it ...
Hi all,

I'm trying to set up a .NET webservice using in data access layer
Nhibernate (nhib 1.2.0 beta).
The first trouble I met was that a webservice cannot serialize Interfaces,
like IList<>.

After I workarounded it, now I get:

System.InvalidOperationException: There was an error generating the XML
document. ---System.InvalidOperationException:
CProxyType<<My_NamespaceNAme>><<MyclassName>>_NHib ernate_ProxyINHibernateProxy_System_Runtime_Serial izationISerializable2
cannot be serialized because it does not have a parameterless constructor.
at System.Xml.Serialization.TypeDesc.CheckSupported()
There is anyone out there using nhibernate for webservices??

Thanks.
Regards

gaddoz

Nov 21 '06 #2
Thanks for the reply Pablo.

So, are you saying that in my pattern I should separate
"Model Objects" from "Nhibernate Objects"?

I don't like this idea!
Now I'm using model objects, a data access layer that uses these objects
against Nhibernate and a business layer that calls the DAL.

What do you suggest me?

Regards
Gaddoz

Pablo Cibraro [MVP] ha scritto:
Hi,

Using the NHibernate entities as messages for a web service is not a good
approach. The client will only receive a xml copy of the entire entity
graph, which sometimes can involve many tables. (It is not going to receive
the entity itself).
In addition, you will have the serialization problems that you mention. It
is better to have a different class representing the web service message (A
simple class decorated with XML serialization attributes) and an adapter
layer that maps the message with the NHibernate entity.

Regards,
Pablo Cibraro.

"gaddoz" <ga************@ANTISPAMgmail.comwrote in message
news:45***********************@reader4.news.tin.it ...
>Hi all,

I'm trying to set up a .NET webservice using in data access layer
Nhibernate (nhib 1.2.0 beta).
The first trouble I met was that a webservice cannot serialize Interfaces,
like IList<>.

After I workarounded it, now I get:

System.InvalidOperationException: There was an error generating the XML
document. ---System.InvalidOperationException:
CProxyType<<My_NamespaceNAme>><<MyclassName>>_NHi bernate_ProxyINHibernateProxy_System_Runtime_Seria lizationISerializable2
cannot be serialized because it does not have a parameterless constructor.
at System.Xml.Serialization.TypeDesc.CheckSupported()
There is anyone out there using nhibernate for webservices??

Thanks.
Regards

gaddoz

Nov 21 '06 #3
"gaddoz" <ga************@ANTISPAMgmail.comwrote in message
news:45**********************@reader2.news.tin.it. ..
Thanks for the reply Pablo.

So, are you saying that in my pattern I should separate
"Model Objects" from "Nhibernate Objects"?

I don't like this idea!
Now I'm using model objects, a data access layer that uses these objects
against Nhibernate and a business layer that calls the DAL.

What do you suggest me?
I suggest that you add a third class of object - Data Transfer Objects
(DTO). You use a DTO to transfer data between the web
Nov 21 '06 #4
"John Saunders" <john.saunders at trizetto.comwrote in message
news:eq**************@TK2MSFTNGP02.phx.gbl...
"gaddoz" <ga************@ANTISPAMgmail.comwrote in message
news:45**********************@reader2.news.tin.it. ..
>Thanks for the reply Pablo.

So, are you saying that in my pattern I should separate
"Model Objects" from "Nhibernate Objects"?

I don't like this idea!
Now I'm using model objects, a data access layer that uses these objects
against Nhibernate and a business layer that calls the DAL.

What do you suggest me?

I suggest that you add a third class of object - Data Transfer Objects
(DTO). You use a DTO to transfer data between the web
Sorry, got sent too soon.

You use a DTO to transfer data between the web service and the client. It is
an object which represents the data in a simple format whose only purpose is
to transfer the data. There is no business logic and no database logic in
these objects, just data.

These will also map more closely to XML, and so will be more likely to be
compatible between client and server. For instance, instead of using
collections, the DTO will use arrays.

This allows you to use whatever business-layer or data layer object you like
inside of your server, yet to only present the data itself to the clients.

John
Nov 21 '06 #5
John Saunders ha scritto:
"John Saunders" <john.saunders at trizetto.comwrote in message
news:eq**************@TK2MSFTNGP02.phx.gbl...
>"gaddoz" <ga************@ANTISPAMgmail.comwrote in message
news:45**********************@reader2.news.tin.it ...
>>Thanks for the reply Pablo.

So, are you saying that in my pattern I should separate
"Model Objects" from "Nhibernate Objects"?

I don't like this idea!
Now I'm using model objects, a data access layer that uses these objects
against Nhibernate and a business layer that calls the DAL.

What do you suggest me?
I suggest that you add a third class of object - Data Transfer Objects
(DTO). You use a DTO to transfer data between the web

Sorry, got sent too soon.

You use a DTO to transfer data between the web service and the client. It is
an object which represents the data in a simple format whose only purpose is
to transfer the data. There is no business logic and no database logic in
these objects, just data.

These will also map more closely to XML, and so will be more likely to be
compatible between client and server. For instance, instead of using
collections, the DTO will use arrays.

This allows you to use whatever business-layer or data layer object you like
inside of your server, yet to only present the data itself to the clients.

John

Many thanks guys.

So, go on for DTO!

Any suggestion for a fast way for moving data between model and dto? :)

Gaddoz
Nov 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Kirk | last post by:
Hi there I come from the "Java world" where I used "Spring" and "Hibernate" in web-application development. Is there anyone who has experience using these frameworks in a .NET / c# setting? Are...
0
by: Aquila Deus | last post by:
The documents on their website are completely wrong. Following is the a real example that works with NHibernate 1.0.2.0: <?xml version="1.0" encoding="utf-8"?> <configuration...
1
by: erin.sebastian | last post by:
Hello All, I am new to hibernate and new to nHibernate. I created a small app and when i try and run it i get the error i posted at the bottom of this message. I am using the helper class that...
0
by: TigrouMeow | last post by:
Hello, I'm trying to make a "clean" webservice, using Nhibernate. I'm facing some issues, but i'm quite the beginner with that kind of system. When there are more than 2 clients connected on my...
0
by: beantaxi | last post by:
Hello all, I'm trying to write a simple program, using VS C# 2005 Express and SQL Server Express with NHib 1.0.2. No matter what I try, I'm unable to connect: cannot open connection at...
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
4
by: IceMan | last post by:
Hi, I am using the configuration object and passing it a Assembly object to load. The assembly object i pass in is from a dll which is in a different folder then the Nhibernate dll. The...
2
by: tim007 | last post by:
Hi All, I wanted to know why and when , should we use NHibernate as a data access layer in a C#.Net Project. Can we opt Nhibernate for its ease of implimentation ? or will it increase...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.