Dual configuration of CSLA.NET - Local and Remote objects

Dual configuration of CSLA.NET - Local and Remote objects

Old forum URL: forums.lhotka.net/forums/t/1700.aspx


Sean D posted on Tuesday, November 07, 2006

Hi All,

I've been using CSLA in my projects sinve VB6 days. Great platform.

My current conundrum is that I want to use CSLA.NET in a smartclient application, and also in ASP.NET webservices. That is:

a) I have a set of business objects that connect to, and use one SQL Server database on one machine. No problem there, just configure remoting or webservices to host the objects. There's no direct connection to ADO.NET from the client machines.

b) I have a set of Oracle PL/SQL scripts that I'm going to wrap in a business object layer (using CSLA.NET). these objects will run the data access code on the oracle server itself. So, I'm going to use either .NET Remoting, or WebServices to host these. I've toyed with developing an ASP.NET WebService to use this, but would like to have a finer level of control over the objects.

My question, therefore, is how do I configure the smartclient app to use my SQL Server CSLA.NET business objects AND also use the other Oracle business objects?

If I configure remoting/web app in the config (CslaDataPortalProxy) I can use only either/or one of the sources.

Has anyone else experienced the same dilemma?

Many thanks,

Sean/

RockfordLhotka replied on Tuesday, November 07, 2006

This has been discussed before. There are two basic answers:
  1. Create your own data portal proxy that understands (through some context) whether to call a remote data portal server, or run locally
  2. Use the RunLocal attribute where you are calling your web services

Chapters 4 and 12 should give you enough information to create your own data portal proxy. Typically you can copy the current one (remoting or whatever), and alter it to decide whether to make a remote call or not. If you do make a remote call, you can typically call into the existing host already built into CSLA.

But for your scenario the RunLocal approach might be simpler. If I understand correctly, you have some objects that need to call a remote data portal, and other objects that need to talk to Oracle via a set of web services. In this latter case, there's no point in going to an app server to call the web services, you are happy calling them directly from the client.

If that's true, then you can simply mark the DataPortal_XYZ methods that call the web services with the RunLocal attribute, thus explicitly preventing the data portal from transferring the call to another machine. The web service calls would occur directly from the current location - typically the client workstation.

xal replied on Tuesday, November 07, 2006

I'm currently working on an app that can work in three modes:
I'd love to have a way to make this more configurable, but the dp assumes remoting if it finds the remoting info in the app config and there's no way around that. So I'm forced to either hack csla or deploy 2 different apps just because of the app config.

I wonder if we could set up a handler to allow us to define which dp to use and perhaps return an instance of our own proxies... that would make things nicer because if you create your own proxies, you don't have to alter csla either.

Any ideas?

RockfordLhotka replied on Tuesday, November 07, 2006

xal:

I'd love to have a way to make this more configurable, but the dp assumes remoting if it finds the remoting info in the app config and there's no way around that. So I'm forced to either hack csla or deploy 2 different apps just because of the app config.


But you aren't locked in. The data portal uses a provider model, and the RemotingProxy is just one provider. You can create your own provider that is more configurable, and have the config file tell the data portal to use that provider (proxy).

So you could create MyApp.ConfigurableProxy, which would look at some other contextual information (of your choice) to decide what to do.

Keep in mind that the proxies are all interface-driven. So your ConfigurableProxy could delegate to the existing RemotingProxy to use remoting, the LocalProxy to go local or whatever.

Sean D replied on Wednesday, November 08, 2006

Thanks for the information Rocky.

Although I would like to be using CSLA.NET objects on my Oracle server, I think I will go down the route of making a simple ASAP.NET WebService, and calling the webmethods the client via [RunLocal] and DataPortal_XYZ methods. I could then encapulate the behaviour in the CSLA objects and provide that abstraction to my developers. (Wow, thanks for that)....

As an OT comment, do you know if its possible to use Oracle stored procs (or packages) generically via a webservice, without having to go through the hassle of actually creating specific methods. That is, is there a generic WebService interface wherein I can say something like:

GenericOracleWebService l_MyWS = new GenericOracleWebService()

// Most likely will return XML though

XMLDocument l_MyResult = l_MyWS.ExecutePackage(username, password, SPName);

Actually, do you know if this is possible with SQL Server?

Many thanks,

Sean.

Sean D replied on Wednesday, November 08, 2006

Thanks for the information Rocky.

Although I would like to be using CSLA.NET objects on my Oracle server, I think I will go down the route of making a simple ASAP.NET WebService, and calling the webmethods the client via [RunLocal] and DataPortal_XYZ methods. I could then encapulate the behaviour in the CSLA objects and provide that abstraction to my developers. (Wow, thanks for that)....

As an OT comment, do you know if its possible to use Oracle stored procs (or packages) generically via a webservice, without having to go through the hassle of actually creating specific methods. That is, is there a generic WebService interface wherein I can say something like:

GenericOracleWebService l_MyWS = new GenericOracleWebService()
// Most likely will return XML
XMLDocument l_MyResult = l_MyWS.ExecutePackage(username, password, SPName);

Actually, do you know if this is possible with SQL Server?

Many thanks,

Sean.

RockfordLhotka replied on Wednesday, November 08, 2006

I know very little about Oracle data access, sorry. Perhaps someone else on the list has better Oracle knowledge...

Copyright (c) Marimer LLC