views:

99

answers:

1

Hi there,

i wish to create a repository pattern but with a WCF Rest Service which controls the data access. Can anyone confirm or help with my thinking / config.

ASP.NET Controllers call to service (not rest service but service of a repository pattern) Repository Pattern Service >> calls to repository Repository >> calls to WCF Rest Service to receive data.

Is this setup good, or should i remove the Repository layer and have the Repository service call directly to the REST Service?

Does anyone do a similar setup?

I would love to hear comments?

Basically my Rest Service (WCF) would return XHTML...

So in my repository layer how would i convert whats returned from my Rest Service into IQUERYABLE? I presume i would need to do ReadAsDataContract into a class (data contract) and then use LINQ to OBJECTS?? This is a causing me a bit of confusing

Becuase of course the normal is to return IQUERYABLE form the repository layer to the service layer

Then the service layer returns to the calling client normal as TOLIST or similar.

Really appreciated any input anyone has.

Thanks

EDIT

Ermm after rethining this, i think i am doing it wrong... i should basically just covert the Service layer of the repository into a WCF REST Service... this way my other clients can call my rest service??

I suppose i keep the Repository layer there but i could get this to call a Data Services layers (technically another rest service) for my data acces..

Does this make better sense?

+2  A: 

By trying to hide the REST layer behind a repository you are attempting to implement distributed objects. REST was never intended as an approach to implement this type of architecture.

If you really want to do REST, you are going about it the wrong way. However, you are far from alone in this pursuit.


Update:

The only place I see a repository for domain objects is on the server, behind the REST interface. All you have on the client is media type handlers and user agent scripts.

Darrel Miller
did you see my edit on my questionn. Is this better? i.e. converting my service layer of my respository to a rest service. Heres is what i said "Ermm after rethining this, i think i am doing it wrong... i should basically just covert the Service layer of the repository into a WCF REST Service... this way my other clients can call my rest service??I suppose i keep the Repository layer there but i could get this to call a Data Services layers (technically another rest service) for my data acces..Does this make better sense?"
Martin
I think this makes more sense doesn't it? Hence my service is converted to a REST service and all my clients can call it (web, windows etc) ... in asp.net mvc i would call my service (now a rest service) from within a controller
Martin
or alternatively would it be better to convert the Repository layer to a rest service.. The repository layer returns Iqueryable though
Martin
Are we talking about the same Repository pattern? http://www.martinfowler.com/eaaCatalog/repository.html I don't know what you mean by "service layer of the repository".
Darrel Miller
Yes Darrel, we are talking about the same repository pattern. But i was using it with the Service layer (also via martin fowler) to make sure my Controllers in ASP.NET MVC were THIN and not FAT.
Martin
Hi darrel, thanks for the update "The only place I see a repository for domain objects is on the server, behind the REST interface. All you have on the client is media type handlers and user agent scripts." THIS is exactly what i was looking for ! So i now have my REST and behind it i have my repository
Martin