Remoting / ExecutionLocation

Remoting / ExecutionLocation

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


lakers72 posted on Friday, February 09, 2007

I am relatively new to CSLA and am haivng trouble with ExecutionLocation.  I have successfully created the remoting host on another box and configured the web.config there and the app.config on my test app.  However, the ExecutionLocation is always client.  As I understand it, with remoting, the actual execution of the code inside my business objects should happen on the server (remoting host).  This is the behavior I need in this case (clients are behind a firewall which does not have certain ports open, therefore I need execution to occur on server).

Here's my app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
       
       
        <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.RemotingProxy, Csla"/>
       
        <add key="CslaDataPortalUrl" value="http://<servername>/remotingportal.rem"/>

        <add key="CslaAuthentication" value="Windows" />
    </appSettings>
   
    <connectionStrings>
    </connectionStrings>
</configuration>

Here's the relevant part of my web.config:
<system.runtime.remoting>
        <application>
            <service>
                <wellknown mode="SingleCall" objectUri="remotingportal.rem"
                type="Csla.Server.Hosts.RemotingPortal, Csla"/>
            </service>
            <channels>
                <channel ref="http">
                    <serverProviders>
                        <provider ref="wsdl"/>
                        <formatter ref="soap" typeFilterLevel="Full"/>
                        <formatter ref="binary" typeFilterLevel="Full"/>
                    </serverProviders>
                </channel>
            </channels>
        </application>
    </system.runtime.remoting>


lakers72 replied on Saturday, February 10, 2007

I think I have figured out the issue.  The objects are created on the remoting proxy (server side) and then passed back to the client.  Business Methods are then executed on the client, not on an anchored BO on the server.  I believe I need to inherit from CommandBase for objects that need to execute code on the server and implement that code in DataPortal_Execute (via DataPortal.Execute), correct?

ajj3085 replied on Monday, February 12, 2007

Only code in the any DataPortal_ methods will be run on the server.  All other code should be running client side.  If you're using remoting, and you have a DataPortal_Create method that isn't marked with RunLocal, any code you call in DataPortal_create should be running on the server.  After the DP_C returns, the BO should have been transfered back.

What you need to do depends on what you're trying to accomplish.  If you have a business rule that fires on property changes and that rule needs access to the database, then a command object to implement that rule is probably best.  Although you'll take a peformance hit, and you need to keep in mind that until you actually update the database, the result of that check may not be valid, because another user may modify the data between the time the rule is checked and the user saves the BO.

To answer your orginal question, if you have remoting setup and are within one of the DataPortal_xxx methods, the location should be server.  Any other time, and the location would be client.  If you don't have remoting setup, it is always client IIRC.

Copyright (c) Marimer LLC