Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Remoting Basic Question

Posted on 2004-10-12
11
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12288772
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
ID: 12289059
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
ID: 12290671
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Guitarman316
ID: 12298901
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
ID: 12299039
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
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12299078
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
ID: 12299400
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
ID: 12299670
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
ID: 12299742
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 150 total points
ID: 12300901
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
ID: 12301108
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 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