How to consume legacy business logic from a silverlight application?

david-shm
david-shm used Ask the Experts™
on
Hello Experts,

I have an XBap system designed as a 3-layer application. The XBap client consumes the logic through a WCF Service using netTcpBinding.

For easy of databinding and to be able to re use data validation built-in my business objects, I choosed to reference the business objects library from the xBap client instead of generating proxies.

These objects implement no logic other than they own basic data validation. The real business logic is implemented inside my WCF service.

Now I'm facing a big challenge. I need to port the xBap to silverlight, so I need my silverlight app. to consume the same business logic (which is also used by a winforms LOB application).

Some problems that arise:

1) Can't reference the business objects library from the silverlight client application because it's compiled as a regular dll and not a silverlight one.

2) Can't compile it as a silverlight library because I'd loose lots of functionallity and obviously is not a good idea anyway. If in the future a new .net platform arises I have no warranties that the modified (silverlight) dll will work.

I had some hope when I discovered RIAServices. I read somewhere I could implement a service and use any kind of DAL. (I have a custom one) but I found no example showing how to put RIAServices on top of an existing business layer. It's worth to say that we don't use (and we are not planning to) LINQ. Every example I found started using RIAServices and writing the business logic from scratch using LINQ.

RIAServices generates databinding-ready client code, but I feel I would have to change the entire business layer and that would be really expensive.

So, the solution seems to be to keep using WCF, specially now that silverlight 3.0 supports a new binary binding, and to work with proxies instead of the actual  business objects.
The problem is that those proxies don't include data validation, property change notification and change tracking, three aspects that my business clasess perform.

RIAServices resolves these and other aspects but it requieres to work with silverlight proyects. WCF (SVCUtil.exe) generates proxies but they are not 'complete' for our needs. So It seems I'll have to develop my own utility for generating those proxies taking a business object as input.

Before I start doing so, I wish to know if anyone has already faced this problem and was able to resolve it in a convinient and painless way.

Thanks in advance,

David

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Aaron JabamaniTechnical Architect
Commented:
If i understood completely,

1. Create "silverlight class library application"
2. Now go to "add  existing item"
3. Select the existing business logic file from ur legacy application from the open dialog.
4. Now you have select "Add as link"(press the down arrow) and not "Add"
5. Repeat step 4 for all the files u want to resue.
6. Build the application and now u have silverlight compatible bussiness logic dll for silverlight application to consume.

Hope this helps.

Author

Commented:
Hi apeter,

I'm afraid this won't work. The problem is that the legacy business classes use many .net features that are not allowed inside a silverlight app. For example, SerializableAttributte. That's the reason I can't compile it as a Silverlight Class Library.
Best regards,

David
This article gave me excelent clues about this matter.

http://www.netfxharmonics.com/2008/11/Understanding-WCF-Services-in-Silverlight-2

I'm following this path.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial