473,473 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 9552
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.