开发者

Are NHibernate and XML Webservices (.asmx) a good match?

I'm looking at new architecture for my site and was wondering if pairing NHibernate with a web service core is a good idea. What I want to do is make my webservice the core of my business, from the site front ends to the utilties I write. I'm trying to make all of my UIs completely ignorant of anything but my service API's.

In a simple strawman experiement, I'm running into issues with Serialzing my Iesi ISets....this is causing me to rethink the strategy altogether.

I know I could just develop a core Library (dll) and reference that in each of my applications, but maintaining that dll's version over a minimum of 6 applications seems like it's going to cause me much pain.

With NHibernate, what are the pro's and con's of those开发者_开发问答 two approaches?


I see no problem in using NHibernate and webservices together - I just don't think it's a good idea to send the entities themselves over "to the other side".

A better approach is to use a set of DTOs that are made for the service - then you won't be running into issues like that of serializing unknown types and such.

You can use a library like AutoMapper to do the mapping from the entities to the DTOs.

There's a lot of stuff written about this, some of it:

http://martinfowler.com/bliki/FirstLaw.html

http://ayende.com/Blog/archive/2009/05/14/the-stripper-pattern.aspx

http://elegantcode.com/2008/04/27/dtos-or-serialized-domain-entities/

DTOs vs Serializing Persisted Entities

As a side note for the service it self, you could design wise use an approach like Davy Brion describes here: http://davybrion.com/blog/2009/11/requestresponse-service-layer-series/


I don't know NHibernate, but want to remind you that you should be using WCF for new web service development, unless you are stuck in the past (.NET 2.0). Microsoft now considers ASMX web services to be "legacy technology", and you can imagine what that means.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜