Providing a .NET class library (which basically defines CRUD operations) as a service

What is the best, efficient, and fastest way to publish an existing (class) library (which basically defines CRUD operations) as a service ( WCF service or WCF data service ) so that it can be used with Silverlight or Ajax . Are there tools (code generators, RAD tools) that can support this? Thanks in advance for your help and tips.

+6
c # service wcf wcf-data-services
source share
3 answers

The best approach is to use WCF to create the wrapper yourself.

You should do this, instead of using some automation to just expose the library directly, because:

  • Security, do you want someone to call the library all the time?
  • Most libraries assume that they are called directly, and not through a service (see Enterprise Development Errors ).
  • WCF has no status by default: you need to decide how to manage any state the library accepts (you will no longer have one client).
  • Did I mention security?
+2
source share

If you're just a dumb dataset, just drop a DataContract on it. (Do not forget the namespace, otherwise you will kick yourself later.) Then you can open it using a web project.

If you have real logic in your class, then you have problems. There is no good way to share business logic with Silverlight applications. They try with RIA Services, but that just doesn't make an assessment.

+1
source share

You should take a look at WCF data services, especially in .NET 4. While you have to create a data context class or classes to expose your objects with IQueryable publishing and IUpdatable implementation, you can take advantage of the support structure provided by WCF data services along with a standardized protocol (OData) for your payload.

In .NET 4 and Visual Studio 2010, WCF data services are becoming more acceptable and are being pushed by Microsoft as a good vehicle for accessing data for Silverlight applications.

I think this is at least worth checking out. There is a lot of information about this on MSDN, although I don’t think it organized very well in places. Here's a link to a section on MSDN when minimizing your own WCF data service using the built-in reflection provider. (The example only shows data search, since it is much simpler than updating data / inserting / deleting, but there is a link in the article on how to implement IUpdatable.)

Getting IQueryable through WCF data services should be pretty fast. IUpdatable will take a little longer (since you need to implement Insert / Update / Delete for each object). But as soon as you start and run it (which should not take too much time), you can then configure security settings, add your own maintenance methods and easily add additional functions and / or objects. This is a good structure for what you are describing.

Hope this helps.

+1
source share

All Articles