Guitarman316
asked on
Remoting Basic Question
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.
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.
ASKER
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.PgSqlCo nnection Conn = new CoreLab.PostgreSql.PgSqlCo nnection() ;
Conn.ConnectionString = "User Id=uname;Password=pwd;Host =192.168.0 .207;Datab ase=PryerD ata";
DataSet ds = new DataSet();
PgSqlDataAdapter dap = new PgSqlDataAdapter("Select * from tblUser", Conn);
dap.Fill(ds, "Users");
return ds;
}
}
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.PgSqlCo
Conn.ConnectionString = "User Id=uname;Password=pwd;Host
DataSet ds = new DataSet();
PgSqlDataAdapter dap = new PgSqlDataAdapter("Select * from tblUser", Conn);
dap.Fill(ds, "Users");
return ds;
}
}
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...
ASKER
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.
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.
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.
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.
ASKER
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.
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.
ASKER
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks for the help
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.