views:

19

answers:

2

Here's the situation.

We have a 3rd party middleware (using SQLServer as a back-end) which we communicate with using an HTTP service link and XMLRPC-like messaging.

The service always returns a dataset as results of any commands that returns something. There is a way to pass an embedded SQL statement to the service.

So, we do not have a direct access to the database.

I'm trying to isolate this service with a layer that would simplify access. I was thinking of using an ORM like NHibernate.

Is this scenario supported by NHibernate or does NH always needs a direct access to the database?

If you have any other suggestions I'm all ears open...

+1  A: 

If I understand you correctly, you're forced to use the 3rd party middle-ware - but it's not easy to deal with?

I've never used NHibernate so I can't speak for that.

Sounds like you want to add a new "service layer" (for want of a better term) on the top that's easier to deal with; the Facade pattern leaps to mind (although that's often used to bundle up a variety of different and disparate interfaces underneath a single cohesive integration point).

Basically you want to define a nice clean set of interfaces / services (in the new service layer); this new layer will then do all the hard work of interacting with the middle-ware - or with the database directly if you get the chance.

I would also suggest making this new layer into a couple of sub-parts: you don't want to go and build a new layer that's tightly coupled to the middle-ware (or database) - use Dependency Injection to isolate the outer facade from the concrete implementation, and maintain loose coupling. That way if the middle-ware disappears you won't directly impact consumers of the new service layer you've built.

Lastly, keep the Interface Segregation Principle (ISP) in mind when designing the new externally facing services.

Free Image Hosting (Full size image here)

Adrian K
That's what I had in mind but still I want to have some way of handling transactions (they are supported by the 3rd party middleware). I was thinking of using the repository and unit of work patterns but somehow I can't seem to wrap my mind around them even after countless days of reading about them. I haven't found yet a good example in source code.
Stecy
A: 

We use NHibernate and it sucks. I would not recommend it for anything. As for as I know, NHibernate does require direct access to the database (or at least you just give NHibernate a connection string like you would any other data access provider). Also, because of that, I'm pretty sure it won't know how to handle Xml datasets.

Interesting - I've never used NHibernate, and of the few people I know who have used it not many swear by it - yet it seems to have a large-ish (?) community.
Adrian K