Solved

Remoting Basic Question

Posted on 2004-10-12
11
202 Views
Last Modified: 2008-02-01
All, In the past of used applications that connect to web services to retreive and modify data in our database server.  I've alsways found it to be somewhat slow, due to xml serialization, but managable for small recordsets.  I'm building a new system now and thought I'd give remoting a shot.

I have gone through the basic remoting walk through from the help to create a remotable type, listener and client apps.  It seems to work fine.  So I've now enhanced it to pull data from our PostgreSql database.  I know that the string that comes back from the original example comes out of the remotabletype class which has to be on the client and server pc's.  I've also noticed that the dll's for the CoreLabs Postgresql assembly need to be on the client pc as well.

So the question is with all of the assemblies having to go on the client as well as the server pc, how do I know that the server is where all the work is really happening from?  I do know if I take the listener down I get an error, but with abosultly everything on both boxes how do I know that the database calls are not coming through the assemblies on the client pc?

I'm sure I'll have a million questions after this one.  

Thanks for any help you can provide.

0
Comment
Question by:Guitarman316
  • 6
  • 5
11 Comments
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
If an objects inhertis from MarshalByRefObject, it will run on the server if it was created on the server. All other objects need to be serializable and they will run on the client. Objects which do not inherit fro MarshalByRefObject and which are not serializable will not be remotable.

In your case, I'd define your own interface and make sure to only use native .NET types on this interface, then explse the interface on the server on a MarshalByRefObject descendant. Each call will then be remoted and you can safely do the work on the server witjout having to worry about installing any database libs on the client.
0
 

Author Comment

by:Guitarman316
Comment Utility
Thanks for the reply.  I am inheriting from MarshalByRefObject for my class.  Are you saying that to get all the data access running off the server I need to drop the Postgresql assemblies and go back to odbc?  Here's what I've got at the moment.

using System;
using System.Data;
using CoreLab.PostgreSql;

      public class RemotableType : MarshalByRefObject
      {
            private string _internalString = "This is the Remotable Type";

            
            public string StringMethod()
            {
                  return _internalString;
            }
            
            public DataSet usersGet()
            {
                  CoreLab.PostgreSql.PgSqlConnection Conn = new CoreLab.PostgreSql.PgSqlConnection();
                  Conn.ConnectionString = "User Id=uname;Password=pwd;Host=192.168.0.207;Database=PryerData";

                  DataSet ds = new DataSet();
            
                  PgSqlDataAdapter dap = new PgSqlDataAdapter("Select * from tblUser", Conn);
            
                  dap.Fill(ds, "Users");
                  return ds;
            }
      }

0
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
No, what I am saying is that if you don't pass a DataSet around but rather have methods (like StringMethod) which use primitives, you'll not have to deploy ANY database stuff on the client...
0
 

Author Comment

by:Guitarman316
Comment Utility
Ok I understand what your saying.  Gotta go back to the original question.  Restating it:  If I have the Host/Listener app on 192.168.0.100 and the client on 192.168.0.200 and I deploy the libs to the client and host, when I call a method on the host to retrieve data is the data retrieved by the host and forward as a dataset to the client?

In testing it appears that the above statement may not be true, but from reading about remoting I get the impression it should be.  Here's why it appears that all data access is coming from the client.  With PostgreSQL I can set it up so that an individual user has access based on login id AND IP address.  If the user logs in from the wrong IP address an error is thrown saying access denied.  My db is running on 192.168.0.50 and I've grenated access only to 192.168.0.100 where the host resides.  When I try to run the method to retreive a dataset I get the access is denied message.  If I change the IP address to 192.168.0.200, it work's fine.  This makes me think that the host is really out of the picture.

So do I have a misconceived notion about remoting?  I guess I'm looking for Web Service type of functionality but with the high performance tcp/binary streams of remoting.
I don't mind deploying all the libs to the client (It's an internal only app) if the database access is really being processed on the host.

By the way all objects for the COreLab.PostgreSql are also MarshalByRefObject.

AvonWyss, I appreciate your help.
0
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
Well, what seems to happen is that the dataset is a MarshalByValueComponent, not a MarshalByRefObject. Therefore, the DataSet is COPIED to the client and if you do anything on the dataset, it will be executed on the client. That's how I unserstand it. But until now I haven't tried to pass around DataSets over remoting, so I don't have first-hand experience for this specific situation.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
However, I've just see in the help that DataAdapter is a MarshalByRefObject. So, if you create a DataAdapter o the server, and use a DataSet which is bound to that DataAdapter and remote it, I guess this would work as expected on the server.
0
 

Author Comment

by:Guitarman316
Comment Utility
If your not passing back a dataset what are you passing back?  Are you returning an array or something else?  Maybe my concept is flawed from the start and there's a better way.
0
 
LVL 14

Expert Comment

by:AvonWyss
Comment Utility
I usually make a rich interface (business logic), so that the client then basically just needs to call single methods of that business logic and it gets the data it needs, structured into arrays of classes, structs, strings, whatever fits the need.
0
 

Author Comment

by:Guitarman316
Comment Utility
Thanks for the feedback.  I've been using datasets so much coming from the web services way of thinking.  I'm reading some articles at the moment that indicate moving to remoting may not be the solution to the xml serialization process.  They are saying that by using a dataset the xml serialization process happens anyway.  Reading a KB article now that suggests a work around, but it states that it has been fixed in asp 2.0.  urge...
0
 
LVL 14

Accepted Solution

by:
AvonWyss earned 50 total points
Comment Utility
I was never a fan od DataSets, don't ask me why, and I therefore have never really used them.

Remoting is fine when you make layered applications, using a presentation layer (the client; this may also be a web frontend or anything) which accesses a business logic which actually does the work, which in turn uses any storage - which never comes in touch with the frontends. Therefore, a change of the storage layer does not affect the interface of the business layer or the presentation layer.
0
 

Author Comment

by:Guitarman316
Comment Utility
I agree.  I stopped accessing data from my client apps quite a while back. I used web services instead of Remoting though.  It appears that in the next version theyhave fixed the issue with the dataset.  I'm considering contiuing on as planned and making use of the upgrade in the next version when it releases.

Thanks for the help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now